@@ -52,24 +52,25 @@ const preProcess = async (destinationPath, tempPath) => {
5252  await  ensureDir ( tempPath ) ;  // Create temp dir for this new build 
5353} ; 
5454
55- const  build  =  async  ( tempPath ,  manifestPath )  =>  { 
55+ const  build  =  async  ( tempPath ,  manifestPath ,   envExtension   =   { } )  =>  { 
5656  const  binPath  =  join ( tempPath ,  'bin' ) ; 
5757  const  zipPath  =  join ( tempPath ,  'zip' ) ; 
58+   const  mergedEnv  =  { ...process . env ,  ...envExtension } ; 
5859
5960  const  webpackPath  =  join ( __dirname ,  'node_modules' ,  '.bin' ,  'webpack' ) ; 
6061  execSync ( 
6162    `${ webpackPath } ${ binPath }  , 
6263    { 
6364      cwd : __dirname , 
64-       env : process . env , 
65+       env : mergedEnv , 
6566      stdio : 'inherit' , 
6667    } , 
6768  ) ; 
6869  execSync ( 
6970    `${ webpackPath } ${ binPath }  , 
7071    { 
7172      cwd : __dirname , 
72-       env : process . env , 
73+       env : mergedEnv , 
7374      stdio : 'inherit' , 
7475    } , 
7576  ) ; 
@@ -132,16 +133,32 @@ const postProcess = async (tempPath, destinationPath) => {
132133  await  remove ( tempPath ) ;  // Clean up temp directory and files 
133134} ; 
134135
136+ const  SUPPORTED_BUILDS  =  [ 'chrome' ,  'firefox' ,  'edge' ] ; 
137+ 
135138const  main  =  async  buildId  =>  { 
139+   if  ( ! SUPPORTED_BUILDS . includes ( buildId ) )  { 
140+     throw  new  Error ( 
141+       `Unexpected build id - "${ buildId } ${ JSON . stringify (  
142+         SUPPORTED_BUILDS ,  
143+       ) }  .`, 
144+     ) ; 
145+   } 
146+ 
136147  const  root  =  join ( __dirname ,  buildId ) ; 
137148  const  manifestPath  =  join ( root ,  'manifest.json' ) ; 
138149  const  destinationPath  =  join ( root ,  'build' ) ; 
139150
151+   const  envExtension  =  { 
152+     IS_CHROME : buildId  ===  'chrome' , 
153+     IS_FIREFOX : buildId  ===  'firefox' , 
154+     IS_EDGE : buildId  ===  'edge' , 
155+   } ; 
156+ 
140157  try  { 
141158    const  tempPath  =  join ( __dirname ,  'build' ,  buildId ) ; 
142159    await  ensureLocalBuild ( ) ; 
143160    await  preProcess ( destinationPath ,  tempPath ) ; 
144-     await  build ( tempPath ,  manifestPath ) ; 
161+     await  build ( tempPath ,  manifestPath ,   envExtension ) ; 
145162
146163    const  builtUnpackedPath  =  join ( destinationPath ,  'unpacked' ) ; 
147164    await  postProcess ( tempPath ,  destinationPath ) ; 
0 commit comments