diff --git a/.gitignore b/.gitignore index dbb9a2e2ad..f1d5c446ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *~ *.sw[mnpcod] *.log +*.lock *.tmp *.tmp.* log.txt diff --git a/scripts/gulp/util.ts b/scripts/gulp/util.ts index 118334ccd2..0e18b2a5bf 100644 --- a/scripts/gulp/util.ts +++ b/scripts/gulp/util.ts @@ -11,6 +11,9 @@ import * as through from 'through2'; import * as uglifyPlugin from 'rollup-plugin-uglify'; import { argv } from 'yargs'; +// These packages lack of types. +const resolveBin = require('resolve-bin'); + export function mergeObjects(obj1: any, obj2: any ) { if (! obj1) { obj1 = {}; @@ -140,7 +143,8 @@ export function copyFile(srcPath: string, destPath: string) { export function runNgc(pathToConfigFile: string, done: Function) { let exec = require('child_process').exec; - var shellCommand = `node --max_old_space_size=8096 ${PROJECT_ROOT}/node_modules/.bin/ngc -p ${pathToConfigFile}`; + let ngcPath = getBinaryPath('@angular/compiler-cli', 'ngc'); + let shellCommand = `node --max_old_space_size=8096 ${ngcPath} -p ${pathToConfigFile}`; exec(shellCommand, function(err, stdout, stderr) { console.log(stdout); @@ -151,7 +155,8 @@ export function runNgc(pathToConfigFile: string, done: Function) { export function runTsc(pathToConfigFile: string, done: Function) { let exec = require('child_process').exec; - var shellCommand = `node --max_old_space_size=8096 ${PROJECT_ROOT}/node_modules/.bin/tsc -p ${pathToConfigFile}`; + let tscPath = getBinaryPath('typescript', 'tsc'); + let shellCommand = `node --max_old_space_size=8096 ${tscPath} -p ${pathToConfigFile}`; exec(shellCommand, function(err, stdout, stderr) { console.log(stdout); @@ -162,7 +167,8 @@ export function runTsc(pathToConfigFile: string, done: Function) { export function runWebpack(pathToWebpackConfig: string, done: Function) { let exec = require('child_process').exec; - let shellCommand = `node --max_old_space_size=8096 ./node_modules/.bin/webpack --config ${pathToWebpackConfig} --display-error-details`; + let webpackPath = getBinaryPath('webpack'); + let shellCommand = `node --max_old_space_size=8096 ${webpackPath} --config ${pathToWebpackConfig} --display-error-details`; exec(shellCommand, function(err, stdout, stderr) { console.log(stdout); @@ -171,6 +177,11 @@ export function runWebpack(pathToWebpackConfig: string, done: Function) { }); } +/** Resolves the path for a node package executable. */ +export function getBinaryPath(packageName: string, executable = packageName): string { + return resolveBin.sync(packageName, {executable}); +} + export function deleteFiles(glob: string[], done: Function) { let del = require('del'); del.sync(glob); @@ -276,4 +287,4 @@ export function getFolderInfo() { componentName: componentName, componentTest: componentTest }; -} \ No newline at end of file +}