diff --git a/tools/gulp/gulpfile.ts b/tools/gulp/gulpfile.ts index 48963fabe045..636fa57715bb 100644 --- a/tools/gulp/gulpfile.ts +++ b/tools/gulp/gulpfile.ts @@ -7,4 +7,4 @@ import './tasks/e2e'; import './tasks/lint'; import './tasks/release'; import './tasks/serve'; -import './tasks/spec'; +import './tasks/unit-test'; diff --git a/tools/gulp/task_helpers.ts b/tools/gulp/task_helpers.ts index 15e074392e4d..03a23ee9c660 100644 --- a/tools/gulp/task_helpers.ts +++ b/tools/gulp/task_helpers.ts @@ -68,12 +68,15 @@ export function sassBuildTask(dest: string, root: string, includePaths: string[] } -/** Create a Gulp task that executes a process. */ +/** Options that can be passed to execTask or execNodeTask. */ export interface ExecTaskOptions { + // Whether to output to STDERR and STDOUT. silent?: boolean; + // If an error happens, this will replace the standard error. errMessage?: string; } +/** Create a task that executes a binary as if from the command line. */ export function execTask(binPath: string, args: string[], options: ExecTaskOptions = {}) { return (done: (err?: string) => void) => { const childProcess = child_process.spawn(binPath, args); @@ -95,14 +98,20 @@ export function execTask(binPath: string, args: string[], options: ExecTaskOptio } else { done(options.errMessage); } - return; + } else { + done(); } - done(); }); } } -export function execNodeTask(packageName: string, executable: string[] | string, args?: string[]) { +/** + * Create a task that executes an NPM Bin, by resolving the binary path then executing it. These are + * binaries that are normally in the `./node_modules/.bin` directory, but their name might differ + * from the package. Examples are typescript, ngc and gulp itself. + */ +export function execNodeTask(packageName: string, executable: string | string[], args?: string[], + options: ExecTaskOptions = {}) { if (!args) { args = executable; executable = undefined; @@ -111,12 +120,11 @@ export function execNodeTask(packageName: string, executable: string[] | string, return (done: (err: any) => void) => { resolveBin(packageName, { executable: executable }, (err: any, binPath: string) => { if (err) { - console.error(err); - return done(err); + done(err); + } else { + // Forward to execTask. + execTask(binPath, args, options)(done); } - - // Forward to execTask. - execTask(binPath, args)(done); }); } } diff --git a/tools/gulp/tasks/ci.ts b/tools/gulp/tasks/ci.ts index 47a0d1753e4d..9b6122dafc55 100644 --- a/tools/gulp/tasks/ci.ts +++ b/tools/gulp/tasks/ci.ts @@ -2,9 +2,13 @@ import {task} from 'gulp'; task('ci:lint', ['ci:forbidden-identifiers', 'lint']); -task('ci:test', ['test:single-run']); -task('ci:e2e', ['e2e']); + task('ci:extract-metadata', [':build:components:ngc']); task('ci:forbidden-identifiers', function() { require('../../../scripts/ci/forbidden-identifiers.js'); }); + +// Travis sometimes does not exit the process and times out. This is to prevent that. +task('ci:test', ['test:single-run'], () => process.exit(0)); +// Travis sometimes does not exit the process and times out. This is to prevent that. +task('ci:e2e', ['e2e'], () => process.exit(0)); diff --git a/tools/gulp/tasks/release.ts b/tools/gulp/tasks/release.ts index 58a971e27604..f9a92d6727b2 100644 --- a/tools/gulp/tasks/release.ts +++ b/tools/gulp/tasks/release.ts @@ -28,6 +28,8 @@ task(':publish:whoami', execTask('npm', ['whoami'], { task(':publish:logout', execTask('npm', ['logout'])); task(':publish', function() { + const label = process.argv.slice(2)[1]; // [0] would be ':publish' + const labelArg = label ? `--tag ${label}` : ''; const currentDir = process.cwd(); readdirSync(DIST_COMPONENTS_ROOT) @@ -40,7 +42,7 @@ task(':publish', function() { } process.chdir(componentPath); - execSync('npm publish'); + execSync(`npm publish --access public ${labelArg}`); }); process.chdir(currentDir); }); diff --git a/tools/gulp/tasks/spec.ts b/tools/gulp/tasks/unit-test.ts similarity index 100% rename from tools/gulp/tasks/spec.ts rename to tools/gulp/tasks/unit-test.ts