Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
chore(infrastructure): Fix local dev server (npm start command) (#3089
Browse files Browse the repository at this point in the history
)

The `npm run screenshot:serve` command was recently broken by a refactoring. It would immediately exit instead of waiting to be killed by the user. That is now fixed.
  • Loading branch information
acdvorak authored Jul 16, 2018
1 parent c213108 commit a2b2782
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
20 changes: 5 additions & 15 deletions test/screenshot/lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,28 +208,18 @@ class Controller {
* @return {!Promise<number>}
*/
async getTestExitCode(reportData) {
const isOnline = await this.cli_.isOnline();
// Don't fail Travis builds when screenshots change. The diffs are reported in GitHub instead.
if (process.env.TRAVIS === 'true') {
return ExitCode.OK;
}

// TODO(acdvorak): Store this directly in the proto so we don't have to recalculate it all over the place
const numChanges =
reportData.screenshots.changed_screenshot_list.length +
reportData.screenshots.added_screenshot_list.length +
reportData.screenshots.removed_screenshot_list.length;

if (numChanges === 0) {
return ExitCode.OK;
}

if (isOnline) {
if (process.env.TRAVIS === 'true') {
return ExitCode.OK;
}
return ExitCode.CHANGES_FOUND;
}

// Allow the report HTTP server to keep running by waiting for a promise that never resolves.
console.log('\nPress Ctrl-C to kill the report server');
await new Promise(() => {});
return numChanges > 0 ? ExitCode.CHANGES_FOUND : ExitCode.OK;
}

/**
Expand Down
18 changes: 10 additions & 8 deletions test/screenshot/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ async function run() {
console.log('Offline mode!');
}

cmd()
.then(
(exitCode = 0) => {
cmd().then(
(exitCode = 0) => {
if (exitCode !== 0) {
process.exit(exitCode);
},
(err) => {
console.error(err);
process.exit(ExitCode.UNKNOWN_ERROR);
});
}
},
(err) => {
console.error(err);
process.exit(ExitCode.UNKNOWN_ERROR);
}
);
} else {
console.error(`Error: Unknown command: '${cli.command}'`);
process.exit(ExitCode.UNSUPPORTED_CLI_COMMAND);
Expand Down

0 comments on commit a2b2782

Please sign in to comment.