@@ -228,17 +228,7 @@ var compilerFilename = "tsc.js";
228228var LKGCompiler = path . join ( LKGDirectory , compilerFilename ) ;
229229var 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
836845task ( "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
862895task ( "private-packages" , [ "typemock" , "vfs" ] ) ;
@@ -866,7 +899,7 @@ var run = path.join(builtLocalDirectory, "run.js");
866899compileFile (
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" } ) ;
0 commit comments