Skip to content

Commit

Permalink
New: Export a run function from index & add bin executable
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Dec 21, 2017
1 parent 97f0650 commit b77252e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions bin/gulp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

'use strict';

require('../')();
16 changes: 10 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"files": [
"index.js",
"lib",
"bin",
"completion"
],
"bin": {
"gulp": "./index.js"
"gulp": "bin/gulp.js"
},
"man": "gulp.1",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test/flags-task-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion test/flags-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/flags-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b77252e

Please sign in to comment.