post label snippet javascript npm programming javascript
get list of files from npm pack npm i git-command-helper //const writeFileSync = requirefs;const spawnAsync = requiregit-command-helper/dist/spawn;//const join = requirepath;spawnAsyncnpm, [pack, --json, --dry-run].thenresult => const parse = JSON.parser
BACKnpm i git-command-helper
//const { writeFileSync } = require('fs');
const { spawnAsync } = require('git-command-helper/dist/spawn');
//const { join } = require('path');
spawnAsync('npm', ['pack', '--json', '--dry-run']).then((result) => {
const parse = JSON.parse(result.stdout)[0];
const { files } = parse;
// uncomment for log to file
//const output = join(__dirname, 'tmp/listpack.txt');
//writeFileSync(output, files.map((o) => o && o.path).join('\n'));
//console.log(output);
console.log(files);
});