Created
November 9, 2019 16:15
-
-
Save Waltari10/edf7ebb0db26b441d0ac51d66bbb8bf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// execSync allows us to run system commands synchronously | |
const { execSync } = require('child_process'); | |
// process.env.PORT is defined by Heroku environment. Use 3200 as fallback if outside of Heroku. | |
const port = process.env.PORT || 3200; | |
// Same as runnin "npm run serve" in terminal | |
execSync(`npm run serve -- -l ${ port} ./build`, (err, stdout, stderr) => { | |
if (err) { | |
// node couldn't execute the command | |
return; | |
} | |
// the *entire* stdout and stderr (buffered) | |
console.log(`${stdout}`); | |
console.log(`${stderr}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment