Skip to content

Commit cda8728

Browse files
committed
Update build script
1 parent 774ed0c commit cda8728

File tree

6 files changed

+79
-46
lines changed

6 files changed

+79
-46
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ install:
2727
- if [ "$TRAVIS_NODE_VERSION" = "6" ]; then
2828
npm uninstall typemock @typescript/vfs @typescript/vfs-path @typescript/vfs-core @typescript/vfs-errors --no-save;
2929
npm run build:private-packages;
30-
npm install file:scripts/typemock file:scripts/vfs file:scripts/vfs-path --no-save;
30+
npm install file:scripts/typemock file:scripts/vfs-errors file:scripts/vfs-core file:scripts/vfs-path file:scripts/vfs --no-save;
3131
fi
3232

3333
cache:

Jakefile.js

Lines changed: 74 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,7 @@ var compilerFilename = "tsc.js";
228228
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
229229
var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
230230

231-
/**
232-
* Executes the compiler
233-
* @param {boolean} useBuiltCompiler
234-
* @param {string[]} args
235-
* @param {function([Error]): void} [callback] A callback to execute after the compilation process ends.
236-
*/
237-
function execCompiler(useBuiltCompiler, args, callback) {
238-
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
239-
var cmd = host + " " + compilerPath + " " + args.join(" ");
240-
console.log(cmd + "\n");
241-
231+
function execAsync(cmd, callback) {
242232
var ex = jake.createExec([cmd]);
243233
// Add listeners for output and error
244234
ex.addListener("stdout", function (output) {
@@ -254,12 +244,31 @@ function execCompiler(useBuiltCompiler, args, callback) {
254244
});
255245
ex.addListener("error", function (error) {
256246
if (callback) {
257-
callback(error || new Error("Compilation unsuccessful"));
247+
callback(error || new Error());
258248
}
259249
});
260250
ex.run();
261251
}
262252

253+
function execNpmInstall(packages, callback) {
254+
var cmd = "npm install --no-save " + packages.join(" ");
255+
console.log(cmd);
256+
execAsync(cmd, callback);
257+
}
258+
259+
/**
260+
* Executes the compiler
261+
* @param {boolean} useBuiltCompiler
262+
* @param {string[]} args
263+
* @param {function([Error]): void} [callback] A callback to execute after the compilation process ends.
264+
*/
265+
function execCompiler(useBuiltCompiler, args, callback) {
266+
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
267+
var cmd = host + " " + compilerPath + " " + args.join(" ");
268+
console.log(cmd + "\n");
269+
execAsync(cmd, callback);
270+
}
271+
263272
/** Compiles a file from a list of sources
264273
* @param {string} outFile value for '--out' command line option
265274
* @param {string[]} sources an array of the names of the source files
@@ -287,10 +296,10 @@ function compile(outFile, sources, prefixes, useBuiltCompiler, opts, callback) {
287296
var startCompileTime = mark();
288297
opts = opts || {};
289298
var options = [
290-
"--noImplicitAny",
291-
"--noImplicitThis",
292-
"--alwaysStrict",
293-
"--noEmitOnError",
299+
"--noImplicitAny",
300+
"--noImplicitThis",
301+
"--alwaysStrict",
302+
"--noEmitOnError",
294303
"--pretty",
295304
"--newLine LF"
296305
];
@@ -378,18 +387,18 @@ function compile(outFile, sources, prefixes, useBuiltCompiler, opts, callback) {
378387
prependFile(prefixes[i], outFile);
379388
}
380389
}
381-
390+
382391
if (callback) {
383392
callback();
384393
}
385-
394+
386395
complete();
387396
}
388397
measure(startCompileTime);
389398
});
390399
}
391400

392-
/**
401+
/**
393402
* Compiles a file from a list of sources
394403
* @param {string} outFile the target file name
395404
* @param {string[]} sources an array of the names of the source files
@@ -834,29 +843,53 @@ task("vfs-errors", function () {
834843
}, { async: true });
835844

836845
task("vfs-path", ["vfs-core", "vfs-errors"], function () {
837-
var startCompileTime = mark();
838-
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs-path/tsconfig.json"], function (error) {
839-
if (error) {
840-
fail("Compilation unsuccessful.");
841-
}
842-
else {
843-
complete();
844-
}
845-
measure(startCompileTime);
846-
});
846+
if (process.env.INSTALL_PRIVATE_DEPS) {
847+
execNpmInstall(["file:scripts/vfs-core", "file:scripts/vfs-errors"], function (error) {
848+
if (error) return fail(error);
849+
compile();
850+
});
851+
}
852+
else {
853+
compile();
854+
}
855+
856+
function compile() {
857+
var startCompileTime = mark();
858+
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs-path/tsconfig.json"], function (error) {
859+
if (error) {
860+
fail("Compilation unsuccessful.");
861+
}
862+
else {
863+
complete();
864+
}
865+
measure(startCompileTime);
866+
});
867+
}
847868
}, { async: true });
848869

849-
task("vfs", ["vfs-path", "vfs-core", "vfs-errors"], function () {
850-
var startCompileTime = mark();
851-
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs/tsconfig.json"], function (error) {
852-
if (error) {
853-
fail("Compilation unsuccessful.");
854-
}
855-
else {
856-
complete();
857-
}
858-
measure(startCompileTime);
859-
});
870+
task("vfs", ["vfs-core", "vfs-errors", "vfs-path", "typemock"], function () {
871+
if (process.env.INSTALL_PRIVATE_DEPS) {
872+
execNpmInstall(["file:scripts/vfs-path", "file:scripts/typemock"], function (error) {
873+
if (error) return fail(error);
874+
compile();
875+
});
876+
}
877+
else {
878+
compile();
879+
}
880+
881+
function compile() {
882+
var startCompileTime = mark();
883+
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs/tsconfig.json"], function (error) {
884+
if (error) {
885+
fail("Compilation unsuccessful.");
886+
}
887+
else {
888+
complete();
889+
}
890+
measure(startCompileTime);
891+
});
892+
}
860893
}, { async: true });
861894

862895
task("private-packages", ["typemock", "vfs"]);
@@ -866,7 +899,7 @@ var run = path.join(builtLocalDirectory, "run.js");
866899
compileFile(
867900
/*outFile*/ run,
868901
/*source*/ harnessSources,
869-
/*prereqs*/[builtLocalDirectory, tscFile, tsserverLibraryFile, "typemock"].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
902+
/*prereqs*/[builtLocalDirectory, tscFile, tsserverLibraryFile, "private-packages"].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
870903
/*prefixes*/[],
871904
/*useBuiltCompiler:*/ true,
872905
/*opts*/ { types: ["node", "mocha", "chai"], lib: "es6" });

jenkins.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ npm install
1414
if [ "$1" = "6" ]; then
1515
npm uninstall typemock @typescript/vfs @typescript/vfs-path @typescript/vfs-core @typescript/vfs-errors --no-save;
1616
npm run build:private-packages;
17-
npm install file:scripts/typemock file:scripts/vfs file:scripts/vfs-path --no-save;
17+
npm install file:scripts/typemock file:scripts/vfs-errors file:scripts/vfs-core file:scripts/vfs-path file:scripts/vfs --no-save;
1818
fi
1919

2020
npm update

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"build": "npm run build:compiler && npm run build:tests",
9494
"build:compiler": "jake local",
9595
"build:tests": "jake tests",
96-
"build:private-packages": "jake private-packages",
96+
"build:private-packages": "jake private-packages INSTALL_PRIVATE_DEPS=1",
9797
"start": "node lib/tsc",
9898
"clean": "jake clean",
9999
"gulp": "gulp",

src/harness/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ namespace compiler {
234234
}
235235
else {
236236
[project] = host.vfs.scanSync(".", "ancestors-or-self", {
237-
accept: (path: string, stats: vfs.FileSystem) => stats.isFile() && host.vfs.stringComparer(vpath.basename(path), "tsconfig.json") === 0
237+
accept: (path, stats) => stats.isFile() && host.vfs.stringComparer(vpath.basename(path), "tsconfig.json") === 0
238238
});
239239
}
240240

src/harness/harnessLanguageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ namespace Harness.LanguageService {
131131
public getFilenames(): string[] {
132132
const fileNames: string[] = [];
133133
this.vfs.scanSync("/", "descendants-or-self", {
134-
accept: (path: string, stats: vfs.FileSystem) => {
134+
accept: (path, stats) => {
135135
if (stats.isFile()) {
136136
const scriptInfo = this.vfs.filemeta(path).get("scriptInfo") as ScriptInfo;
137137
if (scriptInfo && scriptInfo.isRootFile) {

0 commit comments

Comments
 (0)