(args: string[])
| 45 | main(process.argv.slice(2)); |
| 46 | |
| 47 | function main(args: string[]): void { |
| 48 | // This utility expects all of its arguments to be specified in a params file generated by |
| 49 | // bazel (see https://docs.bazel.build/versions/master/skylark/lib/Args.html#use_param_file). |
| 50 | const paramFilePath = args[0]; |
| 51 | |
| 52 | // Bazel params may be surrounded with quotes |
| 53 | function unquoteParameter(s: string) { |
| 54 | return s.replace(/^'(.*)'$/, '$1'); |
| 55 | } |
| 56 | |
| 57 | // Parameters are specified in the file one per line. |
| 58 | const params = fs.readFileSync(paramFilePath, 'utf-8').split('\n').map(unquoteParameter); |
| 59 | |
| 60 | const [ |
| 61 | // Output directory for the npm package. |
| 62 | outputDirExecPath, |
| 63 | |
| 64 | // The package segment of the ng_package rule's label (e.g. 'package/common'). |
| 65 | owningPackageName, |
| 66 | |
| 67 | // JSON data capturing metadata of the package being built. See `PackageMetadata`. |
| 68 | metadataArg, |
| 69 | |
| 70 | // Path to the package's README.md. |
| 71 | readmeMd, |
| 72 | |
| 73 | // Path to the package's LICENSE file. |
| 74 | licenseFile, |
| 75 | |
| 76 | // List of individual ES2022 modules |
| 77 | esm2022Arg, |
| 78 | |
| 79 | // List of static files that should be copied into the package. |
| 80 | staticFilesArg, |
| 81 | |
| 82 | // List of side-effectful entry-points |
| 83 | sideEffectEntryPointsArg, |
| 84 | ] = params; |
| 85 | |
| 86 | const esm2022 = JSON.parse(esm2022Arg) as BazelFileInfo[]; |
| 87 | const staticFiles = JSON.parse(staticFilesArg) as BazelFileInfo[]; |
| 88 | const metadata = JSON.parse(metadataArg) as PackageMetadata; |
| 89 | const sideEffectEntryPoints = JSON.parse(sideEffectEntryPointsArg) as string[]; |
| 90 | |
| 91 | if (readmeMd) { |
| 92 | copyFile(readmeMd, 'README.md'); |
| 93 | } |
| 94 | |
| 95 | if (licenseFile) { |
| 96 | copyFile(licenseFile, 'LICENSE'); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Writes a file with the specified content into the package output. |
| 101 | * @param outputRelativePath Relative path in the output directory where the |
| 102 | * file is written to. |
| 103 | * @param fileContent Content of the file. |
| 104 | */ |
no test coverage detected