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
|
// parse args from CLI
|
||||||
const args = parseArgs();
|
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) {
|
if (runCmd) {
|
||||||
const res = await execCommand(config.cmd);
|
const res = await execCommand(config.cmd);
|
||||||
if (res.code !== 0) process.exit(res.code);
|
if (res.code !== 0) {
|
||||||
data.write(config.dataDir, ident, payload);
|
const err = new Error(`Script exited with code ${res.code}`);
|
||||||
} else {
|
err.exitCode = res.code;
|
||||||
data.write(config.dataDir, ident, payload);
|
err.cmd = res.cmd;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.write(config.dataDir, ident, payload);
|
||||||
|
return payload;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user