17 lines
650 B
JavaScript
17 lines
650 B
JavaScript
import { execFileSync } from "node:child_process";
|
|
import { writeFile } from "node:fs/promises";
|
|
|
|
const npmArgs = [
|
|
"sbom",
|
|
"--package-lock-only",
|
|
"--omit=dev",
|
|
"--sbom-format=cyclonedx",
|
|
"--sbom-type=application",
|
|
];
|
|
const command = process.platform === "win32" ? (process.env.ComSpec || "cmd.exe") : "npm";
|
|
const commandArgs = process.platform === "win32" ? ["/d", "/s", "/c", "npm.cmd " + npmArgs.join(" ")] : npmArgs;
|
|
const output = execFileSync(command, commandArgs, { encoding: "utf8", stdio: ["ignore", "pipe", "inherit"] });
|
|
|
|
await writeFile("certscope-sbom.cdx.json", output, "utf8");
|
|
console.log("Wrote certscope-sbom.cdx.json");
|