Skip to content

Commit

Permalink
fix: ensure .env.development PORT works (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz authored Jul 18, 2023
1 parent 049c0c6 commit 4f62b40
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/scripts/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ if (isDirectoryEmpty(buildPath)) {
console.log(chalk.bold.red(`ERROR: No build found. Please run ${formattedBuildCmd} first.`));
} else {
let configuredPort;
let envConfig;

try {
envConfig = require(path.join(process.cwd(), 'env.config.js'));
configuredPort = envConfig?.PORT || process.env.PORT;
configuredPort = require(path.join(process.cwd(), 'env.config.js'))?.PORT;
} catch (error) {
// pass, consuming applications may not have an `env.config.js` file. This is OK.
// Pass. Consuming applications may not have an `env.config.js` file. This is OK.
}

if (!configuredPort) {
configuredPort = process.env.PORT;
}

// No `PORT` found in `env.config.js` and/or `.env.development|private`, so output a warning.
Expand Down

0 comments on commit 4f62b40

Please sign in to comment.