fix: forward exit codes
This commit is contained in:
parent
67e8aef8a3
commit
1d69fe6c78
|
@ -21,6 +21,15 @@ const localConfig = (filename) => {
|
||||||
return configFile;
|
return configFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const forwardProcessCode = (child) => new Promise((resolve, reject) => {
|
||||||
|
child.on('error', reject);
|
||||||
|
child.on('exit', (code) => {
|
||||||
|
child.off('error', reject);
|
||||||
|
process.exitCode = code;
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const build = async (args = []) => {
|
const build = async (args = []) => {
|
||||||
const {production} = program.opts();
|
const {production} = program.opts();
|
||||||
const babelConfigFile = localConfig('.babelrc.js');
|
const babelConfigFile = localConfig('.babelrc.js');
|
||||||
|
@ -53,13 +62,7 @@ const build = async (args = []) => {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return new Promise((resolve, reject) => {
|
return forwardProcessCode(child);
|
||||||
child.on('error', reject);
|
|
||||||
child.on('exit', (code) => {
|
|
||||||
child.off('error', reject);
|
|
||||||
resolve(code);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
program
|
program
|
||||||
|
@ -106,13 +109,7 @@ const unpublish = async () => {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return new Promise((resolve, reject) => {
|
return forwardProcessCode(child);
|
||||||
child.on('error', reject);
|
|
||||||
child.on('exit', (code) => {
|
|
||||||
child.off('error', reject);
|
|
||||||
resolve(code);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const publish = async () => {
|
const publish = async () => {
|
||||||
|
@ -125,13 +122,7 @@ const publish = async () => {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return new Promise((resolve, reject) => {
|
return forwardProcessCode(child);
|
||||||
child.on('error', reject);
|
|
||||||
child.on('exit', (code) => {
|
|
||||||
child.off('error', reject);
|
|
||||||
resolve(code);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
program
|
program
|
||||||
|
@ -145,7 +136,7 @@ program
|
||||||
|
|
||||||
const lint = () => {
|
const lint = () => {
|
||||||
const configFile = localConfig('.eslintrc.js');
|
const configFile = localConfig('.eslintrc.js');
|
||||||
spawn(
|
const child = spawn(
|
||||||
'eslint',
|
'eslint',
|
||||||
[
|
[
|
||||||
'--config',
|
'--config',
|
||||||
|
@ -164,6 +155,7 @@ const lint = () => {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
return forwardProcessCode(child);
|
||||||
};
|
};
|
||||||
|
|
||||||
program
|
program
|
||||||
|
@ -178,7 +170,7 @@ const test = async () => {
|
||||||
process.argv.splice(watchIndex, 1);
|
process.argv.splice(watchIndex, 1);
|
||||||
}
|
}
|
||||||
await build(['--display', 'none']);
|
await build(['--display', 'none']);
|
||||||
spawn(
|
const child = spawn(
|
||||||
'mocha',
|
'mocha',
|
||||||
(-1 === watchIndex ? [] : ['--watch'])
|
(-1 === watchIndex ? [] : ['--watch'])
|
||||||
.concat([
|
.concat([
|
||||||
|
@ -193,6 +185,7 @@ const test = async () => {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
return forwardProcessCode(child);
|
||||||
};
|
};
|
||||||
|
|
||||||
program
|
program
|
||||||
|
|
Loading…
Reference in New Issue
Block a user