@@ -105,7 +105,7 @@ export abstract class CodeBuilder {
105105 this . _event . emit ( event , arg ) ;
106106 }
107107
108- genSourceInfo ( prevBuilderParams : BuilderParams ) : {
108+ genSourceInfo ( prevBuilderParams : BuilderParams | undefined ) : {
109109 sources : string [ ] ,
110110 params ?: { [ name : string ] : string ; }
111111 paramsModTime ?: number ;
@@ -140,8 +140,10 @@ export abstract class CodeBuilder {
140140 srcList . forEach ( ( srcInf : any ) => {
141141 if ( ! srcInf [ fieldName ] ) return ; // skip if not exist
142142 for ( const expr in parttenInfo ) {
143- const path = ( < string > srcInf [ fieldName ] ) . replace ( / \\ / g, '/' ) ;
144- if ( globmatch . isMatch ( path , expr ) ) {
143+ const searchPath = ( < string > srcInf [ fieldName ] ) . replace ( / \\ / g, '/' )
144+ . replace ( / \. \. \/ / g, '' )
145+ . replace ( / \. \/ / g, '' ) ; // globmatch bug ? it can't parse path which have '.' or '..'
146+ if ( globmatch . isMatch ( searchPath , expr ) ) {
145147 const val = parttenInfo [ expr ] ?. trim ( ) . replace ( / (?: \r \n | \n ) $ / , '' )
146148 if ( srcParams [ srcInf . path ] ) {
147149 srcParams [ srcInf . path ] += ` ${ val || '' } `
@@ -169,11 +171,13 @@ export abstract class CodeBuilder {
169171
170172 // if src options is modified to null but old is not null,
171173 // we need make source recompile
172- const oldSrcParams = prevBuilderParams . sourceParams ;
173- for ( const path in oldSrcParams ) {
174- if ( srcParams [ path ] == undefined && oldSrcParams [ path ] != undefined &&
175- oldSrcParams [ path ] != '' ) {
176- srcParams [ path ] = "" ; // make it empty to trigger recompile
174+ if ( prevBuilderParams ) {
175+ const oldSrcParams = prevBuilderParams . sourceParams ;
176+ for ( const path in oldSrcParams ) {
177+ if ( srcParams [ path ] == undefined && oldSrcParams [ path ] != undefined &&
178+ oldSrcParams [ path ] != '' ) {
179+ srcParams [ path ] = "" ; // make it empty to trigger recompile
180+ }
177181 }
178182 }
179183 }
@@ -349,7 +353,7 @@ export abstract class CodeBuilder {
349353 const memMaxSize = this . getMaxSize ( ) ;
350354 const modeList : string [ ] = [ ] ;
351355 const oldParamsPath = `${ paramsPath } .old` ;
352- const prevParams : BuilderParams = File . IsFile ( oldParamsPath ) ? JSON . parse ( fs . readFileSync ( oldParamsPath , 'utf8' ) ) : { } ;
356+ const prevParams : BuilderParams | undefined = File . IsFile ( oldParamsPath ) ? JSON . parse ( fs . readFileSync ( oldParamsPath , 'utf8' ) ) : undefined ;
353357 const sourceInfo = this . genSourceInfo ( prevParams ) ;
354358
355359 const builderOptions : BuilderParams = {
@@ -402,7 +406,7 @@ export abstract class CodeBuilder {
402406 builderOptions . sha = this . genHashFromCompilerOptions ( builderOptions ) ;
403407
404408 // check whether need rebuild project
405- if ( this . isRebuild ( ) == false ) {
409+ if ( this . isRebuild ( ) == false && prevParams ) {
406410 try {
407411 // not found hash from old params file
408412 if ( prevParams . sha == undefined ) {
0 commit comments