Created
November 10, 2019 06:54
-
-
Save Waltari10/dd6edebbef41afd336d3a925f0880de1 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
// exec allows us to run cmd commands in code | |
const { exec } = 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; | |
console.log('Port: ' + port) | |
const cmdStr = `.\\node_modules\\.bin\\serve -l ${ port} ./build` | |
console.log(cmdStr) | |
// Same as running ".\node_modules\.bin\serve -l 3200 ./build" in cmd | |
exec(cmdStr, (err) => { | |
if (err) { | |
console.error('Something went wrong!', err) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment