-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: start command on Windows (#490)
- Loading branch information
1 parent
f207ba1
commit 1cc21f3
Showing
3 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
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', | ||
}); | ||
} |