Emily Markova | 7b78640 | 2024-01-24 20:05:24 -0800 | [diff] [blame^] | 1 | const fs = require('fs'); |
| 2 | const path = require('path'); |
| 3 | const {spawnSync} = require('child_process'); |
| 4 | |
| 5 | const output_dir = path.join( |
| 6 | process.env.BAZEL_BINDIR, |
| 7 | process.env.BAZEL_PACKAGE |
| 8 | ); |
| 9 | console.log(output_dir); |
| 10 | console.log(process.argv[2]); |
| 11 | console.log(process.cwd()); |
| 12 | const ngsw_config = process.argv[2]; |
| 13 | console.log(`Trying to run ${ngsw_config} ${process.argv.slice(4).join(' ')}`); |
| 14 | const result = spawnSync(ngsw_config, process.argv.slice(4), { |
| 15 | stdout: 'inherit', |
| 16 | stderr: 'inherit', |
| 17 | }); |
| 18 | |
| 19 | if (result.status || result.error || result.signal) { |
| 20 | console.log("Failed to run 'ngsw_config'"); |
| 21 | console.log(`status: ${result.status}`); |
| 22 | console.log(`error: ${result.error}`); |
| 23 | console.log(`signal: ${result.signal}`); |
| 24 | console.log(`stdout: ${result.stdout}`); |
| 25 | console.log(`stderr: ${result.stderr}`); |
| 26 | process.exit(1); |
| 27 | } |
| 28 | |
| 29 | const currentDirectory = process.cwd(); |
| 30 | |
| 31 | // Read the contents of the current directory |
| 32 | console.log(`Contents of the current directory: ${currentDirectory}`); |
| 33 | fs.readdirSync(currentDirectory).forEach((file) => { |
| 34 | console.log(file); |
| 35 | }); |
| 36 | |
| 37 | fs.copyFileSync(path.join(process.argv[4], 'ngsw.json'), process.argv[3]); |