diff --git a/package.json b/package.json index bed47c0f..52528812 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "pretest": "npm run lint", "test": "mocha --async-only --timeout 5000 test/lib test", "cover": "nyc --reporter=lcov --reporter=text-summary npm test", - "coveralls": "nyc --reporter=text-lcov npm test | coveralls" + "coveralls": "nyc --reporter=text-lcov npm test | coveralls", + "ts-test": "gulp --gulpfile test/fixtures/config/flags/gulpfile/autoload-ts/other_folder/gulpfile.exports.ts dist" }, "dependencies": { "ansi-colors": "^1.0.1", @@ -63,7 +64,9 @@ "mocha": "^3.2.0", "nyc": "^13.3.0", "rimraf": "^2.6.1", - "semver": "^5.7.1" + "semver": "^5.7.1", + "ts-node": "^9.0.0", + "typescript": "^4.0.3" }, "keywords": [ "build", diff --git a/test/config-flags-gulpfile.js b/test/config-flags-gulpfile.js index 3ac37ac1..5ad3d02f 100644 --- a/test/config-flags-gulpfile.js +++ b/test/config-flags-gulpfile.js @@ -127,5 +127,28 @@ describe('config: flags.gulpfile', function() { } }); + it('Should autoload ts-node/register for a specified TypeScript gulpfile', function(done) { + this.timeout(0); + + runner + .chdir('flags/gulpfile/autoload-ts') + .gulp('dist') + .run(cb); + + function cb(err, stdout, stderr) { + expect(err).toEqual(null); + expect(stderr).toEqual(''); + + var requiring = eraseTime(headLines(stdout, 1)); + expect(requiring).toEqual('Requiring external module ts-node/register'); + var clean = eraseTime(headLines(stdout, 1, 4)); + expect(clean).toEqual('clean!'); + var build = eraseTime(headLines(stdout, 1, 7)); + expect(build).toEqual('build!'); + + done(err); + } + }); + }); diff --git a/test/fixtures/config/flags/gulpfile/autoload-ts/.gulp.json b/test/fixtures/config/flags/gulpfile/autoload-ts/.gulp.json new file mode 100644 index 00000000..0b95aaa2 --- /dev/null +++ b/test/fixtures/config/flags/gulpfile/autoload-ts/.gulp.json @@ -0,0 +1,5 @@ +{ + "flags": { + "gulpfile": "other_folder/gulpfile-exports.ts" + } +} diff --git a/test/fixtures/config/flags/gulpfile/autoload-ts/other_folder/gulpfile.exports.ts b/test/fixtures/config/flags/gulpfile/autoload-ts/other_folder/gulpfile.exports.ts new file mode 100644 index 00000000..773b8206 --- /dev/null +++ b/test/fixtures/config/flags/gulpfile/autoload-ts/other_folder/gulpfile.exports.ts @@ -0,0 +1,6 @@ +import * as gulp from 'gulp'; + +export function clean(done) { console.log('clean!'); done(); }; +export function build(done) { console.log('build!'); done(); }; +export const string = 'no function'; +export const dist = gulp.series(clean, build);