@@ -176,7 +176,10 @@ var harnessSources = harnessCoreSources.concat([
176176 "reuseProgramStructure.ts" ,
177177 "cachingInServerLSHost.ts" ,
178178 "moduleResolution.ts" ,
179- "tsconfigParsing.ts"
179+ "tsconfigParsing.ts" ,
180+ "commandLineParsing.ts" ,
181+ "convertCompilerOptionsFromJson.ts" ,
182+ "convertTypingOptionsFromJson.ts"
180183] . map ( function ( f ) {
181184 return path . join ( unittestsDirectory , f ) ;
182185} ) ) . concat ( [
@@ -250,51 +253,59 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
250253 * @param prereqs: prerequisite tasks to compiling the file
251254 * @param prefixes: a list of files to prepend to the target file
252255 * @param useBuiltCompiler: true to use the built compiler, false to use the LKG
253- * @param noOutFile: true to compile without using --out
254- * @param generateDeclarations: true to compile using --declaration
255- * @param outDir: true to compile using --outDir
256- * @param keepComments: false to compile using --removeComments
256+ * @parap {Object} opts - property bag containing auxiliary options
257+ * @param {boolean } opts.noOutFile: true to compile without using --out
258+ * @param {boolean } opts.generateDeclarations: true to compile using --declaration
259+ * @param {string } opts.outDir: value for '--outDir' command line option
260+ * @param {boolean } opts.keepComments: false to compile using --removeComments
261+ * @param {boolean } opts.preserveConstEnums: true if compiler should keep const enums in code
262+ * @param {boolean } opts.noResolve: true if compiler should not include non-rooted files in compilation
263+ * @param {boolean } opts.stripInternal: true if compiler should remove declarations marked as @internal
264+ * @param {boolean } opts.noMapRoot: true if compiler omit mapRoot option
257265 * @param callback: a function to execute after the compilation process ends
258266 */
259- function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile , generateDeclarations , outDir , preserveConstEnums , keepComments , noResolve , stripInternal , callback ) {
267+ function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , opts , callback ) {
260268 file ( outFile , prereqs , function ( ) {
261269 var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler ;
262270 var options = "--noImplicitAny --noEmitOnError --pretty" ;
263-
271+ opts = opts || { } ;
264272 // Keep comments when specifically requested
265273 // or when in debug mode.
266- if ( ! ( keepComments || useDebugMode ) ) {
274+ if ( ! ( opts . keepComments || useDebugMode ) ) {
267275 options += " --removeComments" ;
268276 }
269277
270- if ( generateDeclarations ) {
278+ if ( opts . generateDeclarations ) {
271279 options += " --declaration" ;
272280 }
273281
274- if ( preserveConstEnums || useDebugMode ) {
282+ if ( opts . preserveConstEnums || useDebugMode ) {
275283 options += " --preserveConstEnums" ;
276284 }
277285
278- if ( outDir ) {
279- options += " --outDir " + outDir ;
286+ if ( opts . outDir ) {
287+ options += " --outDir " + opts . outDir ;
280288 }
281289
282- if ( ! noOutFile ) {
290+ if ( ! opts . noOutFile ) {
283291 options += " --out " + outFile ;
284292 }
285293 else {
286294 options += " --module commonjs"
287295 }
288296
289- if ( noResolve ) {
297+ if ( opts . noResolve ) {
290298 options += " --noResolve" ;
291299 }
292300
293301 if ( useDebugMode ) {
294- options += " -sourcemap -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
302+ options += " -sourcemap" ;
303+ if ( ! opts . noMapRoot ) {
304+ options += " -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
305+ }
295306 }
296307
297- if ( stripInternal ) {
308+ if ( opts . stripInternal ) {
298309 options += " --stripInternal"
299310 }
300311
@@ -413,13 +424,7 @@ compileFile(/*outfile*/configureNightlyJs,
413424 /*prereqs*/ [ configureNightlyTs ] ,
414425 /*prefixes*/ [ ] ,
415426 /*useBuiltCompiler*/ false ,
416- /*noOutFile*/ false ,
417- /*generateDeclarations*/ false ,
418- /*outDir*/ undefined ,
419- /*preserveConstEnums*/ undefined ,
420- /*keepComments*/ false ,
421- /*noResolve*/ false ,
422- /*stripInternal*/ false ) ;
427+ { noOutFile : false , generateDeclarations : false , keepComments : false , noResolve : false , stripInternal : false } ) ;
423428
424429task ( "setDebugMode" , function ( ) {
425430 useDebugMode = true ;
@@ -473,6 +478,7 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
473478compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
474479
475480var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
481+ var servicesFileInBrowserTest = path . join ( builtLocalDirectory , "typescriptServicesInBrowserTest.js" ) ;
476482var standaloneDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
477483var nodePackageFile = path . join ( builtLocalDirectory , "typescript.js" ) ;
478484var nodeDefinitionsFile = path . join ( builtLocalDirectory , "typescript.d.ts" ) ;
@@ -481,13 +487,7 @@ var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_s
481487compileFile ( servicesFile , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
482488 /*prefixes*/ [ copyright ] ,
483489 /*useBuiltCompiler*/ true ,
484- /*noOutFile*/ false ,
485- /*generateDeclarations*/ true ,
486- /*outDir*/ undefined ,
487- /*preserveConstEnums*/ true ,
488- /*keepComments*/ true ,
489- /*noResolve*/ false ,
490- /*stripInternal*/ true ,
490+ { noOutFile : false , generateDeclarations : true , preserveConstEnums : true , keepComments : true , noResolve : false , stripInternal : true } ,
491491 /*callback*/ function ( ) {
492492 jake . cpR ( servicesFile , nodePackageFile , { silent : true } ) ;
493493
@@ -510,6 +510,16 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
510510 fs . writeFileSync ( nodeStandaloneDefinitionsFile , nodeStandaloneDefinitionsFileContents ) ;
511511 } ) ;
512512
513+ compileFile ( servicesFileInBrowserTest , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
514+ /*prefixes*/ [ copyright ] ,
515+ /*useBuiltCompiler*/ true ,
516+ { noOutFile : false , generateDeclarations : true , preserveConstEnums : true , keepComments : true , noResolve : false , stripInternal : true , noMapRoot : true } ,
517+ /*callback*/ function ( ) {
518+ var content = fs . readFileSync ( servicesFileInBrowserTest ) . toString ( ) ;
519+ var i = content . lastIndexOf ( "\n" ) ;
520+ fs . writeFileSync ( servicesFileInBrowserTest , content . substring ( 0 , i ) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content . substring ( i ) ) ;
521+ } ) ;
522+
513523
514524var serverFile = path . join ( builtLocalDirectory , "tsserver.js" ) ;
515525compileFile ( serverFile , serverSources , [ builtLocalDirectory , copyright ] . concat ( serverSources ) , /*prefixes*/ [ copyright ] , /*useBuiltCompiler*/ true ) ;
@@ -521,8 +531,7 @@ compileFile(
521531 [ builtLocalDirectory , copyright ] . concat ( languageServiceLibrarySources ) ,
522532 /*prefixes*/ [ copyright ] ,
523533 /*useBuiltCompiler*/ true ,
524- /*noOutFile*/ false ,
525- /*generateDeclarations*/ true ) ;
534+ { noOutFile : false , generateDeclarations : true } ) ;
526535
527536// Local target to build the language service server library
528537desc ( "Builds language service server library" ) ;
@@ -681,7 +690,7 @@ function deleteTemporaryProjectOutput() {
681690 }
682691}
683692
684- function runConsoleTests ( defaultReporter , defaultSubsets , postLint ) {
693+ function runConsoleTests ( defaultReporter , defaultSubsets ) {
685694 cleanTestDirs ( ) ;
686695 var debug = process . env . debug || process . env . d ;
687696 tests = process . env . test || process . env . tests || process . env . t ;
@@ -714,13 +723,13 @@ function runConsoleTests(defaultReporter, defaultSubsets, postLint) {
714723 subsetRegexes = subsets . map ( function ( sub ) { return "^" + sub + ".*$" ; } ) ;
715724 subsetRegexes . push ( "^(?!" + subsets . join ( "|" ) + ").*$" ) ;
716725 }
717- subsetRegexes . forEach ( function ( subsetRegex ) {
726+ subsetRegexes . forEach ( function ( subsetRegex , i ) {
718727 tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '' ;
719728 var cmd = "mocha" + ( debug ? " --debug-brk" : "" ) + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run ;
720729 console . log ( cmd ) ;
721730 exec ( cmd , function ( ) {
722731 deleteTemporaryProjectOutput ( ) ;
723- if ( postLint ) {
732+ if ( i === 0 ) {
724733 var lint = jake . Task [ 'lint' ] ;
725734 lint . addListener ( 'complete' , function ( ) {
726735 complete ( ) ;
@@ -742,7 +751,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio
742751
743752desc ( "Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false." ) ;
744753task ( "runtests" , [ "build-rules" , "tests" , builtLocalDirectory ] , function ( ) {
745- runConsoleTests ( 'mocha-fivemat-progress-reporter' , [ ] , /*postLint*/ true ) ;
754+ runConsoleTests ( 'mocha-fivemat-progress-reporter' , [ ] ) ;
746755} , { async : true } ) ;
747756
748757desc ( "Generates code coverage data via instanbul" ) ;
@@ -755,7 +764,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
755764// Browser tests
756765var nodeServerOutFile = 'tests/webTestServer.js'
757766var nodeServerInFile = 'tests/webTestServer.ts'
758- compileFile ( nodeServerOutFile , [ nodeServerInFile ] , [ builtLocalDirectory , tscFile ] , [ ] , /*useBuiltCompiler:*/ true , /* noOutFile*/ true ) ;
767+ compileFile ( nodeServerOutFile , [ nodeServerInFile ] , [ builtLocalDirectory , tscFile ] , [ ] , /*useBuiltCompiler:*/ true , { noOutFile : true } ) ;
759768
760769desc ( "Runs browserify on run.js to produce a file suitable for running tests in the browser" ) ;
761770task ( "browserify" , [ "tests" , builtLocalDirectory , nodeServerOutFile ] , function ( ) {
@@ -764,7 +773,7 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
764773} , { async : true } ) ;
765774
766775desc ( "Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]" ) ;
767- task ( "runtests-browser" , [ "tests" , "browserify" , builtLocalDirectory ] , function ( ) {
776+ task ( "runtests-browser" , [ "tests" , "browserify" , builtLocalDirectory , servicesFileInBrowserTest ] , function ( ) {
768777 cleanTestDirs ( ) ;
769778 host = "node"
770779 port = process . env . port || process . env . p || '8888' ;
@@ -916,7 +925,8 @@ var tslintRulesOutFiles = tslintRules.map(function(p) {
916925desc ( "Compiles tslint rules to js" ) ;
917926task ( "build-rules" , tslintRulesOutFiles ) ;
918927tslintRulesFiles . forEach ( function ( ruleFile , i ) {
919- compileFile ( tslintRulesOutFiles [ i ] , [ ruleFile ] , [ ruleFile ] , [ ] , /*useBuiltCompiler*/ false , /*noOutFile*/ true , /*generateDeclarations*/ false , path . join ( builtLocalDirectory , "tslint" ) ) ;
928+ compileFile ( tslintRulesOutFiles [ i ] , [ ruleFile ] , [ ruleFile ] , [ ] , /*useBuiltCompiler*/ false ,
929+ { noOutFile : true , generateDeclarations : false , outDir : path . join ( builtLocalDirectory , "tslint" ) } ) ;
920930} ) ;
921931
922932function getLinterOptions ( ) {
@@ -955,6 +965,7 @@ var servicesLintTargets = [
955965 "patternMatcher.ts" ,
956966 "services.ts" ,
957967 "shims.ts" ,
968+ "jsTyping.ts"
958969] . map ( function ( s ) {
959970 return path . join ( servicesDirectory , s ) ;
960971} ) ;
0 commit comments