diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..257888c9 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +**/*.babel.js diff --git a/.jscsrc b/.jscsrc index 703b33fc..9f7071c3 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,3 +1,4 @@ { - "preset": "gulp" + "preset": "gulp", + "excludeFiles": ["**/*.babel.js"] } diff --git a/lib/shared/registerExports.js b/lib/shared/registerExports.js index 572e9edc..09a31d0b 100644 --- a/lib/shared/registerExports.js +++ b/lib/shared/registerExports.js @@ -14,7 +14,7 @@ function registerExports(gulpInst, tasks) { return; } - gulpInst.task(task.displayName || taskName, task); + gulpInst.task(taskName, task); } } diff --git a/package.json b/package.json index 9a6ff3f8..2dc29e35 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,8 @@ "yargs": "^3.28.0" }, "devDependencies": { + "babel-preset-es2015": "^6.5.0", + "babel-register": "^6.5.1", "code": "^1.2.1", "coveralls": "^2.7.0", "eslint": "^1.7.3", diff --git a/test/expected/tasks-as-exports.txt b/test/expected/tasks-as-exports.txt new file mode 100644 index 00000000..e8214270 --- /dev/null +++ b/test/expected/tasks-as-exports.txt @@ -0,0 +1,7 @@ +gulp-cli/test +├── build +├── clean +└─┬ dist + └─┬ + ├── clean + └── build diff --git a/test/exports-as-tasks.js b/test/exports-as-tasks.js new file mode 100644 index 00000000..96533ad5 --- /dev/null +++ b/test/exports-as-tasks.js @@ -0,0 +1,26 @@ +'use strict'; + +var lab = exports.lab = require('lab').script(); +var code = require('code'); +var fs = require('fs'); +var child = require('child_process'); + +var output = fs.readFileSync(__dirname + '/expected/tasks-as-exports.txt', 'utf8').replace(/(\r\n|\n|\r)/gm,'\n'); + +// Long timeout is required because parse time is slow +lab.experiment('exports as tasks', { timeout: 0 }, function() { + + lab.test('prints the task list', function(done) { + + child.exec('node ' + __dirname + '/../bin/gulp.js --tasks --gulpfile "./test/fixtures/gulpfile-exports.babel.js"', function(err, stdout) { + code.expect(stdout).to.contain('Tasks for'); + stdout = stdout.replace(/\\/g, '/').split('Tasks for')[1].split('\n'); + var outputArray = output.split('\n'); + for (var i = 0; i < stdout.length; i++) { + code.expect(stdout[i]).to.contain(outputArray[i]); + } + done(err); + }); + }); + +}); diff --git a/test/fixtures/.babelrc b/test/fixtures/.babelrc new file mode 100644 index 00000000..c13c5f62 --- /dev/null +++ b/test/fixtures/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/test/fixtures/gulpfile-exports.babel.js b/test/fixtures/gulpfile-exports.babel.js new file mode 100644 index 00000000..514fdb30 --- /dev/null +++ b/test/fixtures/gulpfile-exports.babel.js @@ -0,0 +1,9 @@ +// jscs:disable + +'use strict'; + +import gulp from 'gulp'; + +export function clean(){}; +export function build(){}; +export const dist = gulp.series(clean, build);