const { execSync } = require('child_process');
const path = require('path');
module.exports.runPack = function runPack() {
  const cwd = path.join(__dirname, '..');
  // run npm pack and capture output
  const out = execSync('npm pack', { cwd, encoding: 'utf8' }).trim();
  // npm pack prints the filename on the last line
  const lines = out.split(/\r?\n/).filter(Boolean);
  const filename = lines[lines.length - 1];
  return { cwd, filename };
};
