Skip to content

Commit

Permalink
fix: start command on Windows (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
tisoap authored and nicolodavis committed Oct 14, 2019
1 parent f207ba1 commit 1cc21f3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "library for turn-based games",
"repository": "https://github.com/nicolodavis/boardgame.io",
"scripts": {
"start": "bash ./scripts/dev.sh",
"dev:client": "(cd examples/react-web; npm start)",
"start": "node scripts/install-web.js && npx concurrently npm:dev:server npm:dev:client",
"dev:client": "cd examples && cd react-web && npm start",
"dev:server": "cross-env NODE_ENV=development nodemon -w src -w examples -e js,ts --exec babel-node --extensions '.ts,.js' --ignore 'src/**/*.test.ts' --presets @babel/preset-env examples/react-web/server.js",
"build": "cross-env BABEL_ENV=rollup rollup --config rollup.npm.js",
"benchmark": "babel-node --presets @babel/preset-env benchmark/index.js",
Expand Down
15 changes: 0 additions & 15 deletions scripts/dev.sh

This file was deleted.

35 changes: 35 additions & 0 deletions scripts/install-web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2019 The boardgame.io Authors
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/

const path = require('path');
const { spawnSync } = require('child_process');
const { existsSync } = require('fs');

const projectRoot = path.resolve(__dirname, '../');
const webExamplePath = path.resolve(projectRoot, './examples/react-web');
const modulesPath = path.resolve(webExamplePath, './node_modules');

const hasModules = existsSync(modulesPath);

if (!hasModules) {
installDependencies();
}

console.log('Starting the application...');

function installDependencies() {
const isWindowsOs = process.platform === 'win32';
const npmCommand = isWindowsOs ? 'npm.cmd' : 'npm';

console.log('Installing web dependencies...');

spawnSync(npmCommand, ['install'], {
cwd: webExamplePath,
stdio: 'inherit',
});
}

0 comments on commit 1cc21f3

Please sign in to comment.