Skip to content

Commit

Permalink
Fixed issue #488: npm run dev race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack committed Oct 30, 2016
1 parent dce2082 commit f552462
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test-watch": "npm test -- --watch",
"test-e2e": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 mocha --retries 2 --compilers js:babel-register --require ./test/setup.js ./test/e2e.js",
"lint": "eslint --format=node_modules/eslint-formatter-pretty app test *.js",
"hot-server": "cross-env NODE_ENV=development node -r babel-register server.js",
"hot-server": "cross-env NODE_ENV=development node --max_old_space_size=2096 -r babel-register server.js",
"build-main": "cross-env NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.electron.js --progress --profile --colors",
"build-renderer": "cross-env NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.production.js --progress --profile --colors",
"build": "npm run build-main && npm run build-renderer",
Expand All @@ -18,7 +18,7 @@
"package": "cross-env NODE_ENV=production node -r babel-register -r babel-polyfill package.js",
"package-all": "npm run package -- --all",
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
"dev": "concurrently --kill-others \"npm run hot-server\" \"npm run start-hot\"",
"dev": "npm run hot-server",
"cleanup": "mop -v"
},
"bin": {
Expand Down
15 changes: 13 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import express from 'express';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import { exec } from 'child_process';

import config from './webpack.config.development';

Expand All @@ -29,10 +30,20 @@ app.use(webpackHotMiddleware(compiler));

const server = app.listen(PORT, 'localhost', err => {
if (err) {
console.error(err);
return;
return console.error(err);
}

exec('npm run start-hot', (_error, stdout, stderr) => {
if (_error) {
return console.error(`exec error: ${_error}`);
}

return [
console.log(`stdout: ${stdout}`),
console.log(`stderr: ${stderr}`)
];
});

console.log(`Listening at http://localhost:${PORT}`);
});

Expand Down

0 comments on commit f552462

Please sign in to comment.