Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass through program exit code when using start-autorest-express #240

Merged
merged 2 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .scripts/start-autorest-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ function prepend( color,pText ,text) {
// (b) run the given command line.
// when the (b) completes, terminate (a)

// This variable stores the exit code of the program that gets launched by
// this script so that it can be passed through for use in CI reporting, etc
let wrappedExitCode = 0;

async function main() {

const cmdArgs = [];
Expand Down Expand Up @@ -92,7 +96,7 @@ async function main() {
verbose('Express is ready.')

if (!interactive) {
await execute(command, cmdArgs, {
const result = await execute(command, cmdArgs, {
onCreate: (proc) => {
verbose(`Started command: '${command} ${cmdArgs.join(' ')}'`);
cmdProc = proc;
Expand All @@ -109,6 +113,9 @@ async function main() {
});
running = false;
verbose('Command completed.');

// Store the exit code so that it can be returned when this process exits
wrappedExitCode = result.error;
} else {
await queryUser('\n\nPress enter to stop testserver\n');
}
Expand Down Expand Up @@ -139,6 +146,7 @@ async function main() {
async function start() {
try {
await main();
process.exit(wrappedExitCode);
} catch (e) {
console.error(e);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/autorest.testserver",
"version": "2.10.65",
"version": "2.10.66",
"main": "./legacy/startup/www.js",
"bin": {
"start-autorest-express": "./.scripts/start-autorest-express.js",
Expand Down