fix: reject form module, don't exit
also resolve with the payload information
This commit is contained in:
@@ -36,4 +36,8 @@ function buildConfig(args) {
|
||||
// parse args from CLI
|
||||
const args = parseArgs();
|
||||
|
||||
pkgcomp(buildConfig(args), utils.getIdent(), args);
|
||||
pkgcomp(buildConfig(args), utils.getIdent(), args).catch(err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
process.exit(err.exitCode);
|
||||
});
|
||||
|
||||
13
src/index.js
13
src/index.js
@@ -54,9 +54,14 @@ module.exports = async function pkgcomp(config, ident, opts = defaultOptions) {
|
||||
|
||||
if (runCmd) {
|
||||
const res = await execCommand(config.cmd);
|
||||
if (res.code !== 0) process.exit(res.code);
|
||||
data.write(config.dataDir, ident, payload);
|
||||
} else {
|
||||
data.write(config.dataDir, ident, payload);
|
||||
if (res.code !== 0) {
|
||||
const err = new Error(`Script exited with code ${res.code}`);
|
||||
err.exitCode = res.code;
|
||||
err.cmd = res.cmd;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
data.write(config.dataDir, ident, payload);
|
||||
return payload;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user