8000 command line Argument support for both yarn and npm (#629) · etherscan-io/electron-vue@a420471 · GitHub
[go: up one dir, main page]

Skip to content

Commit a420471

Browse files
jeeftorXanderLuciano
authored andcommitted
command line Argument support for both yarn and npm (SimulatedGREG#629)
* Adding NPM/YARN compatibility to command line args * added command line param note * Update dev-runner.js Improve formatting * Remove end of file newline Remove automatically inserted newline at end of file
1 parent 04efb17 commit a420471

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

docs/en/npm_scripts.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Build your app for production and package. More info can be found in the [**Buil
1010

1111
Run app in development.
1212

13+
You can also pass command line paramaters to the application with:
14+
15+
npm run dev --arg1=val1 --arg2
16+
1317
### `npm run lint`
1418

1519
Lint all your `src/`'s and `test/`'s JS & Vue component files.

template/.electron-vue/dev-runner.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,20 @@ function startMain () {
114114
}
115115

116116
function startElectron () {
117-
electronProcess = spawn(electron, ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')])
117+
var args = [
118+
'--inspect=5858',
119+
path.join(__dirname, '../dist/electron/main.js')
120+
]
121+
122+
// detect yarn or npm and process commandline args accordingly
123+
if (process.env.npm_execpath.endsWith('yarn.js')) {
124+
args = args.concat(process.argv.slice(3))
125+
} else if (process.env.npm_execpath.endsWith('npm-cli.js')) {
126+
args = args.concat(process.argv.slice(2))
127+
}
118128

129+
electronProcess = spawn(electron, args)
130+
119131
electronProcess.stdout.on('data', data => {
120132
electronLog(data, 'blue')
121133
})
@@ -175,4 +187,4 @@ function init () {
175187
})
176188
}
177189

178-
init()
190+
init()

0 commit comments

Comments
 (0)
0