-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·24 lines (18 loc) · 792 Bytes
/
cli.js
File metadata and controls
executable file
·24 lines (18 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const { spawn } = require('child_process')
const webpackConfigPath = path.resolve(__dirname, 'webpack.config.js')
let webpackBinPath = path.resolve(__dirname, 'node_modules/webpack/bin/webpack.js')
if (!fs.existsSync(webpackBinPath)) {
// when using newer versions of npx, node modules are not inside swift-react folder
webpackBinPath = path.resolve(__dirname, '../webpack/bin/webpack.js')
}
if (!fs.existsSync(webpackBinPath)) {
console.log(`\nCouldn't find webpack binary to start webpack server. Please raise an issue at https://github.com/mesaugat/swift-react/issues`)
process.exit(1)
}
spawn(`${webpackBinPath} serve --config ${webpackConfigPath} --open`, [], {
shell: true,
stdio: 'inherit'
})