MCPcopy
hub / github.com/Fission-AI/OpenSpec / npmPack

Function npmPack

scripts/pack-version-check.mjs:27–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27function npmPack() {
28 try {
29 const jsonOut = run('npm', ['pack', '--json', '--silent']);
30 const arr = JSON.parse(jsonOut);
31 if (Array.isArray(arr) && arr.length > 0) {
32 const last = arr[arr.length - 1];
33 const file = (last && typeof last === 'object' && last.filename) || (typeof last === 'string' ? last : null);
34 if (file) return String(file).trim();
35 }
36 // Unexpected JSON shape or empty array; fallback to plain output
37 const out = run('npm', ['pack', '--silent']).trim();
38 const lines = out.split(/\r?\n/);
39 return lines[lines.length - 1].trim();
40 } catch (e) {
41 // Fallback for environments not supporting --json
42 const out = run('npm', ['pack', '--silent']).trim();
43 const lines = out.split(/\r?\n/);
44 return lines[lines.length - 1].trim();
45 }
46}
47
48function main() {
49 const pkg = JSON.parse(readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'));

Callers 1

mainFunction · 0.85

Calls 1

runFunction · 0.85

Tested by

no test coverage detected