From 0bd5659dbaf7dbdf52edc2bca20ba8c58a2f1b00 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 9 Feb 2016 13:47:05 -0700 Subject: [PATCH] back out displayName change from #53 - add regression test --- .eslintignore | 1 + .jscsrc | 3 ++- lib/shared/registerExports.js | 2 +- package.json | 2 ++ test/expected/tasks-as-exports.txt | 7 +++++++ test/exports-as-tasks.js | 26 +++++++++++++++++++++++++ test/fixtures/.babelrc | 3 +++ test/fixtures/gulpfile-exports.babel.js | 9 +++++++++ 8 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .eslintignore create mode 100644 test/expected/tasks-as-exports.txt create mode 100644 test/exports-as-tasks.js create mode 100644 test/fixtures/.babelrc create mode 100644 test/fixtures/gulpfile-exports.babel.js 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);