Skip to content

Commit cc40042

Browse files
authored
Fix the makeArtifactList script to be less sensitive to NPM version (#6790)
1 parent 96693e9 commit cc40042

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

scripts/makeArtifactList.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,21 @@ const isCheckMode = process.argv.includes("-check");
1818
const rootPath = path.join(__dirname, "..");
1919
const fileListPath = path.join(rootPath, "packages", "artifacts.txt");
2020

21-
const output = spawnSync(`npm pack --dry-run`, {
21+
const output = spawnSync(`npm pack --dry-run --json`, {
2222
cwd: rootPath,
2323
encoding: "utf8",
2424
shell: true,
25-
}).stderr;
25+
}).stdout;
2626

27-
let files = output
28-
.slice(
29-
output.indexOf("Tarball Contents"),
30-
output.lastIndexOf("npm notice === Tarball Details ===")
31-
)
32-
.split("\n")
33-
.map(x => x.split(" ").filter(Boolean))
34-
.filter(x => x[0] === "npm" && x[1] === "notice")
35-
.map(x => x[x.length - 1]);
27+
const [{ files }] = JSON.parse(output);
28+
let filePaths = files.map(file => file.path);
3629

3730
if (!isCheckMode) {
38-
files = Array.from(new Set(files.concat(getFilesAddedByCI())));
31+
filePaths = Array.from(new Set(filePaths.concat(getFilesAddedByCI())));
3932
}
4033

41-
files.sort();
42-
fs.writeFileSync(fileListPath, files.join("\n"));
34+
filePaths.sort();
35+
fs.writeFileSync(fileListPath, filePaths.join("\n"));
4336

4437
if (isCheckMode) {
4538
execSync(`git diff --exit-code ${fileListPath}`, { stdio: "inherit" });

0 commit comments

Comments
 (0)