@@ -29,11 +29,11 @@ function mkdirp(p) {
2929 }
3030}
3131
32- function copyWithReplace ( src , dest , replacements , renameBuildFiles ) {
32+ function copyWithReplace ( src , dest , substitutions , renameBuildFiles ) {
3333 mkdirp ( path . dirname ( dest ) ) ;
3434 if ( ! isBinary ( src ) ) {
3535 let content = fs . readFileSync ( src , { encoding : 'utf-8' } ) ;
36- replacements . forEach ( r => {
36+ substitutions . forEach ( r => {
3737 const [ regexp , newvalue ] = r ;
3838 content = content . replace ( regexp , newvalue ) ;
3939 } ) ;
@@ -59,20 +59,20 @@ function unquoteArgs(s) {
5959function main ( args ) {
6060 args = fs . readFileSync ( args [ 0 ] , { encoding : 'utf-8' } ) . split ( '\n' ) . map ( unquoteArgs ) ;
6161 const
62- [ outDir , baseDir , srcsArg , binDir , genDir , depsArg , packagesArg , replacementsArg , packPath ,
62+ [ outDir , baseDir , srcsArg , binDir , genDir , depsArg , packagesArg , substitutionsArg , packPath ,
6363 publishPath , replaceWithVersion , stampFile , vendorExternalArg , renameBuildFilesArg ,
6464 runNpmTemplatePath ] = args ;
6565 const renameBuildFiles = parseInt ( renameBuildFilesArg ) ;
6666
67- const replacements = [
67+ const substitutions = [
6868 // Strip content between BEGIN-INTERNAL / END-INTERNAL comments
6969 [ / ( # | \/ \/ ) \s + B E G I N - I N T E R N A L [ \w \W ] + ?E N D - I N T E R N A L / g, '' ] ,
7070 ] ;
71- const rawReplacements = JSON . parse ( replacementsArg ) ;
71+ const rawReplacements = JSON . parse ( substitutionsArg ) ;
7272 for ( let key of Object . keys ( rawReplacements ) ) {
73- replacements . push ( [ new RegExp ( key , 'g' ) , rawReplacements [ key ] ] )
73+ substitutions . push ( [ new RegExp ( key , 'g' ) , rawReplacements [ key ] ] )
7474 }
75- // Replace version last so that earlier replacements can add
75+ // Replace version last so that earlier substitutions can add
7676 // the version placeholder
7777 if ( replaceWithVersion ) {
7878 let version = '0.0.0' ;
@@ -92,7 +92,7 @@ function main(args) {
9292 version = versionTag . split ( ' ' ) [ 1 ] . trim ( ) ;
9393 }
9494 }
95- replacements . push ( [ new RegExp ( replaceWithVersion , 'g' ) , version ] ) ;
95+ substitutions . push ( [ new RegExp ( replaceWithVersion , 'g' ) , version ] ) ;
9696 }
9797
9898 // src like baseDir/my/path is just copied to outDir/my/path
@@ -101,7 +101,7 @@ function main(args) {
101101 if ( src . startsWith ( 'external/' ) ) {
102102 // If srcs is from external workspace drop the external/wksp portion
103103 copyWithReplace (
104- src , path . join ( outDir , src . split ( '/' ) . slice ( 2 ) . join ( '/' ) ) , replacements ,
104+ src , path . join ( outDir , src . split ( '/' ) . slice ( 2 ) . join ( '/' ) ) , substitutions ,
105105 renameBuildFiles ) ;
106106 } else {
107107 // Source is from local workspace
@@ -111,7 +111,7 @@ function main(args) {
111111 `generated file should belong in 'deps' instead.` ) ;
112112 }
113113 copyWithReplace (
114- src , path . join ( outDir , path . relative ( baseDir , src ) ) , replacements , renameBuildFiles ) ;
114+ src , path . join ( outDir , path . relative ( baseDir , src ) ) , substitutions , renameBuildFiles ) ;
115115 }
116116 }
117117
@@ -140,7 +140,7 @@ function main(args) {
140140 // Deps like bazel-bin/baseDir/my/path is copied to outDir/my/path.
141141 for ( dep of depsArg . split ( ',' ) . filter ( s => ! ! s ) ) {
142142 try {
143- copyWithReplace ( dep , outPath ( dep ) , replacements , renameBuildFiles ) ;
143+ copyWithReplace ( dep , outPath ( dep ) , substitutions , renameBuildFiles ) ;
144144 } catch ( e ) {
145145 console . error ( `Failed to copy ${ dep } to ${ outPath ( dep ) } ` ) ;
146146 throw e ;
@@ -168,7 +168,7 @@ function main(args) {
168168 return file ;
169169 }
170170 copyWithReplace (
171- path . join ( base , file ) , path . join ( outDir , outFile ( ) ) , replacements , renameBuildFiles ) ;
171+ path . join ( base , file ) , path . join ( outDir , outFile ( ) ) , substitutions , renameBuildFiles ) ;
172172 }
173173 }
174174 fs . readdirSync ( pkg ) . forEach ( f => {
0 commit comments