| 155 | const SUPPORTED_BUILDS = ['chrome', 'firefox', 'edge']; |
| 156 | |
| 157 | const main = async buildId => { |
| 158 | if (!SUPPORTED_BUILDS.includes(buildId)) { |
| 159 | throw new Error( |
| 160 | `Unexpected build id - "${buildId}". Use one of ${JSON.stringify( |
| 161 | SUPPORTED_BUILDS, |
| 162 | )}.`, |
| 163 | ); |
| 164 | } |
| 165 | |
| 166 | const root = join(__dirname, buildId); |
| 167 | const manifestPath = join(root, 'manifest.json'); |
| 168 | const destinationPath = join(root, 'build'); |
| 169 | |
| 170 | const envExtension = { |
| 171 | IS_CHROME: buildId === 'chrome', |
| 172 | IS_FIREFOX: buildId === 'firefox', |
| 173 | IS_EDGE: buildId === 'edge', |
| 174 | }; |
| 175 | |
| 176 | try { |
| 177 | const tempPath = join(__dirname, 'build', buildId); |
| 178 | await ensureLocalBuild(); |
| 179 | await preProcess(destinationPath, tempPath); |
| 180 | const webpackStatsFilePath = await build( |
| 181 | tempPath, |
| 182 | manifestPath, |
| 183 | envExtension, |
| 184 | ); |
| 185 | |
| 186 | const builtUnpackedPath = join(destinationPath, 'unpacked'); |
| 187 | await postProcess(tempPath, destinationPath, webpackStatsFilePath); |
| 188 | |
| 189 | return builtUnpackedPath; |
| 190 | } catch (error) { |
| 191 | console.error(error); |
| 192 | process.exit(1); |
| 193 | } |
| 194 | |
| 195 | return null; |
| 196 | }; |
| 197 | |
| 198 | module.exports = main; |
nothing calls this directly
no test coverage detected