@@ -9,7 +9,6 @@ import runSequence = require("run-sequence");
99import concat = require( "gulp-concat" ) ;
1010import clone = require( "gulp-clone" ) ;
1111import newer = require( "gulp-newer" ) ;
12- import gIf = require( "gulp-if" ) ;
1312import tsc = require( "gulp-typescript" ) ;
1413declare module "gulp-typescript" {
1514 interface Settings {
@@ -32,7 +31,6 @@ import browserify = require("browserify");
3231import through2 = require( "through2" ) ;
3332import merge2 = require( "merge2" ) ;
3433import intoStream = require( "into-stream" ) ;
35- import lazypipe = require( "lazypipe" ) ;
3634import * as os from "os" ;
3735import Linter = require( "tslint" ) ;
3836const gulp = helpMaker ( originalGulp ) ;
@@ -435,16 +433,18 @@ const nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
435433const nodeDefinitionsFile = path . join ( builtLocalDirectory , "typescript.d.ts" ) ;
436434const nodeStandaloneDefinitionsFile = path . join ( builtLocalDirectory , "typescript_standalone.d.ts" ) ;
437435
438- const prependCopyright = lazypipe ( )
439- . pipe ( ( ) => insert . prepend ( fs . readFileSync ( copyright ) ) ) ;
436+ let copyrightContent : string ;
437+ function prependCopyright ( outputCopyright : boolean = ! useDebugMode ) {
438+ return insert . prepend ( outputCopyright ? ( copyrightContent || ( copyrightContent = fs . readFileSync ( copyright ) . toString ( ) ) ) : "" ) ;
439+ }
440440
441441gulp . task ( builtLocalCompiler , false , [ servicesFile ] , ( ) => {
442442 const localCompilerProject = tsc . createProject ( "src/compiler/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
443443 return localCompilerProject . src ( )
444444 . pipe ( newer ( builtLocalCompiler ) )
445445 . pipe ( sourcemaps . init ( ) )
446446 . pipe ( tsc ( localCompilerProject ) )
447- . pipe ( gIf ( useDebugMode , prependCopyright ( ) ) )
447+ . pipe ( prependCopyright ( ) )
448448 . pipe ( sourcemaps . write ( "." ) )
449449 . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
450450} ) ;
@@ -455,9 +455,9 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
455455 . pipe ( newer ( servicesFile ) )
456456 . pipe ( sourcemaps . init ( ) )
457457 . pipe ( tsc ( servicesProject ) ) ;
458- const completedJs = js . pipe ( gIf ( useDebugMode , prependCopyright ( ) ) )
458+ const completedJs = js . pipe ( prependCopyright ( ) )
459459 . pipe ( sourcemaps . write ( "." ) ) ;
460- const completedDts = dts . pipe ( prependCopyright ( ) )
460+ const completedDts = dts . pipe ( prependCopyright ( /*outputCopyright*/ true ) )
461461 . pipe ( insert . transform ( ( contents , file ) => {
462462 file . path = standaloneDefinitionsFile ;
463463 return contents . replace ( / ^ ( \s * ) ( e x p o r t ) ? c o n s t e n u m ( \S + ) { ( \s * ) $ / gm, "$1$2enum $3 {$4" ) ;
@@ -489,7 +489,7 @@ gulp.task(serverFile, false, [servicesFile], () => {
489489 . pipe ( newer ( serverFile ) )
490490 . pipe ( sourcemaps . init ( ) )
491491 . pipe ( tsc ( serverProject ) )
492- . pipe ( gIf ( useDebugMode , prependCopyright ( ) ) )
492+ . pipe ( prependCopyright ( ) )
493493 . pipe ( sourcemaps . write ( "." ) )
494494 . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
495495} ) ;
@@ -508,10 +508,10 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
508508 . pipe ( tsc ( settings ) ) ;
509509
510510 return merge2 ( [
511- js . pipe ( gIf ( useDebugMode , prependCopyright ( ) ) )
511+ js . pipe ( prependCopyright ( ) )
512512 . pipe ( sourcemaps . write ( "." ) )
513513 . pipe ( gulp . dest ( "." ) ) ,
514- dts . pipe ( gIf ( useDebugMode , prependCopyright ( ) ) )
514+ dts . pipe ( prependCopyright ( ) )
515515 . pipe ( gulp . dest ( "." ) )
516516 ] ) ;
517517} ) ;
0 commit comments