Permalink
Browse files

New: Export a run function from index & add bin executable

  • Loading branch information...
phated committed Dec 29, 2014
1 parent 97f0650 commit b77252e89dc66a880b2e12b1b25dd5457d9887b6
Showing with 20 additions and 10 deletions.
  1. +5 −0 bin/gulp.js
  2. +10 −6 index.js
  3. +2 −1 package.json
  4. +1 −1 test/flags-task-simple.js
  5. +1 −1 test/flags-tasks.js
  6. +1 −1 test/flags-version.js
@@ -0,0 +1,5 @@
#!/usr/bin/env node
'use strict';
require('../')();
@@ -64,12 +64,16 @@ cli.on('respawn', function (flags, child) {
gutil.log('Respawned to PID:', pid);
});
cli.launch({
cwd: argv.cwd,
configPath: argv.gulpfile,
require: argv.require,
completion: argv.completion
}, handleArguments);
function run() {
cli.launch({
cwd: argv.cwd,
configPath: argv.gulpfile,
require: argv.require,
completion: argv.completion
}, handleArguments);
}
module.exports = run;
// the actual logic
function handleArguments(env) {
@@ -17,10 +17,11 @@
"files": [
"index.js",
"lib",
"bin",
"completion"
],
"bin": {
"gulp": "./index.js"
"gulp": "bin/gulp.js"
},
"man": "gulp.1",
"dependencies": {
@@ -11,7 +11,7 @@ var output = fs.readFileSync(__dirname + '/expected/flags-tasks-simple.txt', 'ut
lab.experiment('flag: --tasks-simple', function () {
lab.test('prints the task list', function (done) {
child.exec('node ' + __dirname + '/../index.js --tasks-simple --cwd ./test', function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --tasks-simple --cwd ./test', function(err, stdout) {
code.expect(stdout).to.equal(output);
done(err);
});
@@ -8,7 +8,7 @@ var child = require('child_process');
lab.experiment('flag: --tasks', function () {
lab.test('prints the task list', function (done) {
child.exec('node ' + __dirname + '/../index.js --tasks --cwd ./test', function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --tasks --cwd ./test', function(err, stdout) {
stdout = stdout.replace(/\\/g, '/');
code.expect(stdout).to.contain('/gulp-cli/test');
code.expect(stdout).to.contain('├── test1');
@@ -11,7 +11,7 @@ var gulpVersion = require('gulp/package.json').version;
lab.experiment('flag: --version', function () {
lab.test('prints the task list', function (done) {
child.exec('node ' + __dirname + '/../index.js --version --cwd ./test', function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --version --cwd ./test', function(err, stdout) {
code.expect(stdout).to.contain('CLI version ' + cliVersion);
code.expect(stdout).to.contain('Local version ' + gulpVersion);
done(err);

0 comments on commit b77252e

Please sign in to comment.