mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
7155e9e5e2
Attempting to run as is fails because we have `"type": "module"`. `shelljs` is a CommonJS module however, so we need to do a default import and destructure.
```
$ node packages/compiler-cli/test/compliance/update_all_goldens.js
const {exec} = require('shelljs');
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/douglasparker/Source/ng/packages/compiler-cli/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///home/douglasparker/Source/ng/packages/compiler-cli/test/compliance/update_all_goldens.js:11:16
at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12)
```
PR Close #44916
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
// tslint:disable:no-console
|
|
import shelljs from 'shelljs';
|
|
const {exec} = shelljs;
|
|
|
|
process.stdout.write('Gathering all partial golden update targets');
|
|
const queryCommand =
|
|
`yarn -s bazel query --output label 'filter('golden.update', kind(nodejs_binary, //packages/compiler-cli/test/compliance/test_cases:*))'`;
|
|
const allUpdateTargets =
|
|
exec(queryCommand, {silent: true}).trim().split('\n').map(test => test.trim());
|
|
process.stdout.clearLine();
|
|
process.stdout.cursorTo(0);
|
|
|
|
for (const [index, target] of allUpdateTargets.entries()) {
|
|
const progress = `${index + 1} / ${allUpdateTargets.length}`;
|
|
process.stdout.write(`[${progress}] Running: ${target}`);
|
|
const commandResult = exec(`yarn -s bazel run ${target}`, {silent: true});
|
|
process.stdout.clearLine();
|
|
process.stdout.cursorTo(0);
|
|
if (commandResult.code) {
|
|
console.error(`[${progress}] Failed run: ${target}`);
|
|
console.group();
|
|
console.error(commandResult.stdout || commandResult.stderr);
|
|
console.groupEnd();
|
|
} else {
|
|
console.log(`[${progress}] Successful run: ${target}`);
|
|
}
|
|
}
|