diff --git a/.travis.yml b/.travis.yml index 42b86fb0706..8b924a336fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ install: - if [ "$TRAVIS_NODE_VERSION" = "6" ]; then npm uninstall typemock @typescript/vfs @typescript/vfs-path @typescript/vfs-core @typescript/vfs-errors --no-save; npm run build:private-packages; - npm install file:scripts/typemock file:scripts/vfs file:scripts/vfs-path --no-save; + npm install file:scripts/typemock file:scripts/vfs-errors file:scripts/vfs-core file:scripts/vfs-path file:scripts/vfs --no-save; fi cache: diff --git a/Jakefile.js b/Jakefile.js index a1b847d0511..c7f69bed8fa 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -228,17 +228,7 @@ var compilerFilename = "tsc.js"; var LKGCompiler = path.join(LKGDirectory, compilerFilename); var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); -/** - * Executes the compiler - * @param {boolean} useBuiltCompiler - * @param {string[]} args - * @param {function([Error]): void} [callback] A callback to execute after the compilation process ends. - */ -function execCompiler(useBuiltCompiler, args, callback) { - var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; - var cmd = host + " " + compilerPath + " " + args.join(" "); - console.log(cmd + "\n"); - +function execAsync(cmd, callback) { var ex = jake.createExec([cmd]); // Add listeners for output and error ex.addListener("stdout", function (output) { @@ -254,12 +244,31 @@ function execCompiler(useBuiltCompiler, args, callback) { }); ex.addListener("error", function (error) { if (callback) { - callback(error || new Error("Compilation unsuccessful")); + callback(error || new Error()); } }); ex.run(); } +function execNpmInstall(packages, callback) { + var cmd = "npm install --no-save " + packages.join(" "); + console.log(cmd); + execAsync(cmd, callback); +} + +/** + * Executes the compiler + * @param {boolean} useBuiltCompiler + * @param {string[]} args + * @param {function([Error]): void} [callback] A callback to execute after the compilation process ends. + */ +function execCompiler(useBuiltCompiler, args, callback) { + var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; + var cmd = host + " " + compilerPath + " " + args.join(" "); + console.log(cmd + "\n"); + execAsync(cmd, callback); +} + /** Compiles a file from a list of sources * @param {string} outFile value for '--out' command line option * @param {string[]} sources an array of the names of the source files @@ -287,10 +296,10 @@ function compile(outFile, sources, prefixes, useBuiltCompiler, opts, callback) { var startCompileTime = mark(); opts = opts || {}; var options = [ - "--noImplicitAny", - "--noImplicitThis", - "--alwaysStrict", - "--noEmitOnError", + "--noImplicitAny", + "--noImplicitThis", + "--alwaysStrict", + "--noEmitOnError", "--pretty", "--newLine LF" ]; @@ -378,18 +387,18 @@ function compile(outFile, sources, prefixes, useBuiltCompiler, opts, callback) { prependFile(prefixes[i], outFile); } } - + if (callback) { callback(); } - + complete(); } measure(startCompileTime); }); } -/** +/** * Compiles a file from a list of sources * @param {string} outFile the target file name * @param {string[]} sources an array of the names of the source files @@ -834,29 +843,53 @@ task("vfs-errors", function () { }, { async: true }); task("vfs-path", ["vfs-core", "vfs-errors"], function () { - var startCompileTime = mark(); - execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs-path/tsconfig.json"], function (error) { - if (error) { - fail("Compilation unsuccessful."); - } - else { - complete(); - } - measure(startCompileTime); - }); + if (process.env.INSTALL_PRIVATE_DEPS) { + execNpmInstall(["file:scripts/vfs-core", "file:scripts/vfs-errors"], function (error) { + if (error) return fail(error); + compile(); + }); + } + else { + compile(); + } + + function compile() { + var startCompileTime = mark(); + execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs-path/tsconfig.json"], function (error) { + if (error) { + fail("Compilation unsuccessful."); + } + else { + complete(); + } + measure(startCompileTime); + }); + } }, { async: true }); -task("vfs", ["vfs-path", "vfs-core", "vfs-errors"], function () { - var startCompileTime = mark(); - execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs/tsconfig.json"], function (error) { - if (error) { - fail("Compilation unsuccessful."); - } - else { - complete(); - } - measure(startCompileTime); - }); +task("vfs", ["vfs-core", "vfs-errors", "vfs-path", "typemock"], function () { + if (process.env.INSTALL_PRIVATE_DEPS) { + execNpmInstall(["file:scripts/vfs-path", "file:scripts/typemock"], function (error) { + if (error) return fail(error); + compile(); + }); + } + else { + compile(); + } + + function compile() { + var startCompileTime = mark(); + execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs/tsconfig.json"], function (error) { + if (error) { + fail("Compilation unsuccessful."); + } + else { + complete(); + } + measure(startCompileTime); + }); + } }, { async: true }); task("private-packages", ["typemock", "vfs"]); @@ -866,7 +899,7 @@ var run = path.join(builtLocalDirectory, "run.js"); compileFile( /*outFile*/ run, /*source*/ harnessSources, - /*prereqs*/[builtLocalDirectory, tscFile, tsserverLibraryFile, "typemock"].concat(libraryTargets).concat(servicesSources).concat(harnessSources), + /*prereqs*/[builtLocalDirectory, tscFile, tsserverLibraryFile, "private-packages"].concat(libraryTargets).concat(servicesSources).concat(harnessSources), /*prefixes*/[], /*useBuiltCompiler:*/ true, /*opts*/ { types: ["node", "mocha", "chai"], lib: "es6" }); diff --git a/jenkins.sh b/jenkins.sh index ef9f9535c6f..fe1a88fbbe0 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -14,7 +14,7 @@ npm install if [ "$1" = "6" ]; then npm uninstall typemock @typescript/vfs @typescript/vfs-path @typescript/vfs-core @typescript/vfs-errors --no-save; npm run build:private-packages; - npm install file:scripts/typemock file:scripts/vfs file:scripts/vfs-path --no-save; + npm install file:scripts/typemock file:scripts/vfs-errors file:scripts/vfs-core file:scripts/vfs-path file:scripts/vfs --no-save; fi npm update diff --git a/package.json b/package.json index 66af769602d..f6c9cac9792 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "build": "npm run build:compiler && npm run build:tests", "build:compiler": "jake local", "build:tests": "jake tests", - "build:private-packages": "jake private-packages", + "build:private-packages": "jake private-packages INSTALL_PRIVATE_DEPS=1", "start": "node lib/tsc", "clean": "jake clean", "gulp": "gulp", diff --git a/src/harness/compiler.ts b/src/harness/compiler.ts index 00647dccf20..b6481612d80 100644 --- a/src/harness/compiler.ts +++ b/src/harness/compiler.ts @@ -234,7 +234,7 @@ namespace compiler { } else { [project] = host.vfs.scanSync(".", "ancestors-or-self", { - accept: (path: string, stats: vfs.FileSystem) => stats.isFile() && host.vfs.stringComparer(vpath.basename(path), "tsconfig.json") === 0 + accept: (path, stats) => stats.isFile() && host.vfs.stringComparer(vpath.basename(path), "tsconfig.json") === 0 }); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index af14f2c2f8f..7ad66449efe 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -131,7 +131,7 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; this.vfs.scanSync("/", "descendants-or-self", { - accept: (path: string, stats: vfs.FileSystem) => { + accept: (path, stats) => { if (stats.isFile()) { const scriptInfo = this.vfs.filemeta(path).get("scriptInfo") as ScriptInfo; if (scriptInfo && scriptInfo.isRootFile) {