@onereach/orest-input-cli
Version:
The tool for creating, serving, and publishing OREST Inputs
33 lines (24 loc) • 816 B
JavaScript
const path = require('path');
const runNpmScript = require('./runNpmScript');
const isFileExist = require('./isFileExist');
async function packBundle({
packageName,
packageVersion,
relDirPath = '',
fromNpm = false,
}) {
let additionalArgs = [];
if (fromNpm) {
additionalArgs = [`${packageName}@${packageVersion}`];
}
const name = packageName.replace('@', '').replace('/', '-');
const fileName = `${name}-${packageVersion}.tgz`;
const filePath = path.resolve(process.cwd(), relDirPath, fileName);
const destFileName = `${name}-${packageVersion}.npmpack.tgz`;
const isExist = await isFileExist(filePath);
if (!isExist) {
await runNpmScript('pack', additionalArgs, relDirPath, { noRun: true });
}
return { filePath, fileName, destFileName };
}
module.exports = packBundle;