Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/command_add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

module.exports = function (task, exec, done) {
var options = task.options({
directory: null,
files: null
});

var args = ['add'];

if (options.directory) {
args.push('-C ' + options.directory);
}

if (options.files && options.files.length === 1 && options.files[0] === '*') {
args.push('.');
}
//else{} //TO DO: add individual files

// Add callback
args.push(done);

exec.apply(this, args);
};

module.exports.description = 'Add files to a repository';
39 changes: 39 additions & 0 deletions lib/command_init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

var ArgUtil = require('flopmang');

module.exports = function (task, exec, done) {
var argUtil = new ArgUtil(task, [
{ // <template>
option: 'template',
defaultValue: null,
useAsFlag: true,
useValue: true,
required: false,
flag: '--template'
},
{ // <separateGitDir>
option: 'separateGitDir',
defaultValue: null,
useAsFlag: true,
useValue: true,
required: false,
flag: '--separate-git-dir'
},
{ // <directory>
option: 'directory',
defaultValue: null,
useAsFlag: false,
useValue: true,
required: false
}
]);

var args = ['init'].concat(argUtil.getArgFlags());

args.push(done);

exec.apply(this, args);
};

module.exports.description = 'Init a repository.';
2 changes: 2 additions & 0 deletions lib/commands.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module.exports = {
add: require('./command_add'),
archive: require('./command_archive'),
checkout: require('./command_checkout'),
clean: require('./command_clean'),
clone: require('./command_clone'),
commit: require('./command_commit'),
init: require('./command_init'),
merge: require('./command_merge'),
pull: require('./command_pull'),
push: require('./command_push'),
Expand Down
36 changes: 36 additions & 0 deletions test/add_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var command = require('../lib/commands').add;
var Test = require('./_common');

describe('add', function () {
it('add', function (done) {
var options = {
};

new Test(command, options)
.expect(['add'])
.run(done);
});

it('add all files', function (done) {
var options = {
files: ['*']
};

new Test(command, options)
.expect(['add', '.'])
.run(done);
});

it('should add all files to a specified directory', function (done) {
var options = {
directory: 'testDirectory',
files: ['*']
};

new Test(command, options)
.expect(['add', '-C testDirectory', '.'])
.run(done);
});
});
45 changes: 45 additions & 0 deletions test/init_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

var command = require('../lib/commands').init;
var Test = require('./_common');

describe('init', function () {
it('should init a repo', function (done) {
var options = {
};

new Test(command, options)
.expect(['init'])
.run(done);
});

it('should init a repo from a template', function (done) {
var options = {
template: 'testTemplate',
};

new Test(command, options)
.expect(['init', '--template', 'testTemplate'])
.run(done);
});

it('should init a with separate git directory (1)', function (done) {
var options = {
separateGitDir: 'newDir'
};

new Test(command, options)
.expect(['init', '--separate-git-dir', 'newDir'])
.run(done);
});

it('should init a in a specified git directory (2)', function (done) {
var options = {
directory: 'newDir'
};

new Test(command, options)
.expect(['init', 'newDir'])
.run(done);
});
});