Skip to content

Commit 145db6d

Browse files
committed
[skip ci] fix(build/serve): rename commands to electron:command
1 parent 6a244cf commit 145db6d

19 files changed

+106
-68
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ That's It! You're ready to go!
2222

2323
If you use [Yarn](https://yarnpkg.com/en/) (strongly recommended):
2424

25-
`yarn serve:electron`
25+
`yarn electron:serve`
2626

2727
or if you use NPM:
2828

29-
`npm run serve:electron`
29+
`npm run electron:serve`
3030

3131
### To build your app:
3232

3333
With Yarn:
3434

35-
`yarn build:electron`
35+
`yarn electron:build`
3636

3737
or with NPM:
3838

39-
`npm run build:electron`
39+
`npm run electron:build`
4040

4141
To see more documentation, [visit our website](https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/guide.html).

__tests__/build.helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const runTests = useTS =>
1515
path.join(process.cwd(), '__tests__/projects/' + projectName, p)
1616

1717
const { stdout } = await project.run(
18-
`vue-cli-service build:electron --x64 ${
18+
`vue-cli-service electron:build --x64 ${
1919
isWin ? '--win zip' : ''
2020
} --linux zip`
2121
)

__tests__/build.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ jest.setTimeout(600000)
22

33
const runTests = require('./build.helper.js').runTests
44

5-
test('build:electron', async () => {
5+
test('electron:build', async () => {
66
await runTests()
77
})

__tests__/buildTS.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ jest.setTimeout(600000)
22

33
const runTests = require('./build.helper.js').runTests
44

5-
test('build:electron-ts', async () => {
5+
test('electron:build-ts', async () => {
66
await runTests(true)
77
})

__tests__/commands.spec.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ const runCommand = async (command, options = {}, args = {}, rawArgs = []) => {
8282
}
8383
// #endregion
8484

85-
describe('build:electron', () => {
85+
describe('electron:build', () => {
8686
process.env.NODE_ENV = 'production'
8787

8888
test('typescript is disabled when set in options', async () => {
89-
await runCommand('build:electron', {
89+
await runCommand('electron:build', {
9090
pluginOptions: {
9191
electronBuilder: {
9292
disableMainProcessTypescript: true
@@ -106,7 +106,7 @@ describe('build:electron', () => {
106106
})
107107

108108
test('custom background file is used if provided', async () => {
109-
await runCommand('build:electron', {
109+
await runCommand('electron:build', {
110110
pluginOptions: {
111111
electronBuilder: {
112112
mainProcessFile: 'customBackground.js'
@@ -122,7 +122,7 @@ describe('build:electron', () => {
122122
})
123123

124124
test('custom output dir is used if set in vue.config.js', async () => {
125-
await runCommand('build:electron', {
125+
await runCommand('electron:build', {
126126
pluginOptions: {
127127
electronBuilder: {
128128
outputDir: 'output'
@@ -142,7 +142,7 @@ describe('build:electron', () => {
142142
})
143143

144144
test('custom output dir is used if dest arg is passed', async () => {
145-
await runCommand('build:electron', {}, { dest: 'output' })
145+
await runCommand('electron:build', {}, { dest: 'output' })
146146

147147
const mainConfig = webpack.mock.calls[0][0]
148148
// Main config output is correct
@@ -156,7 +156,7 @@ describe('build:electron', () => {
156156
})
157157

158158
test('Custom main process webpack config is used if provided', async () => {
159-
await runCommand('build:electron', {
159+
await runCommand('electron:build', {
160160
pluginOptions: {
161161
electronBuilder: {
162162
chainWebpackMainProcess: config => {
@@ -172,12 +172,12 @@ describe('build:electron', () => {
172172
})
173173

174174
test('process.env.IS_ELECTRON is set to true', async () => {
175-
await runCommand('build:electron')
175+
await runCommand('electron:build')
176176
expect(process.env.IS_ELECTRON).toBe('true')
177177
})
178178

179179
test('Custom Electron Builder config is used if provided', async () => {
180-
await runCommand('build:electron', {
180+
await runCommand('electron:build', {
181181
pluginOptions: {
182182
electronBuilder: {
183183
builderOptions: {
@@ -193,7 +193,7 @@ describe('build:electron', () => {
193193
test('Fonts folder is copied to css if it exists', async () => {
194194
// Mock existence of fonts folder
195195
fs.existsSync.mockReturnValueOnce(true)
196-
await runCommand('build:electron')
196+
await runCommand('electron:build')
197197
// css/fonts folder was created
198198
expect(fs.ensureDirSync.mock.calls[1][0]).toBe(
199199
'projectPath/dist_electron/bundled/css/fonts'
@@ -208,7 +208,7 @@ describe('build:electron', () => {
208208
})
209209

210210
test('.js and .ts are merged into file extensions', async () => {
211-
await runCommand('build:electron')
211+
await runCommand('electron:build')
212212

213213
const mainConfig = webpack.mock.calls[0][0]
214214
// Both .js and .ts are resolved
@@ -221,61 +221,61 @@ describe('build:electron', () => {
221221
['--skipBundle'],
222222
['--dest', 'output']
223223
])('%s argument is removed from electron-builder args', async (...args) => {
224-
await runCommand('build:electron', {}, {}, ['--keep1', ...args, '--keep2'])
224+
await runCommand('electron:build', {}, {}, ['--keep1', ...args, '--keep2'])
225225
// Custom args should have been removed, and other args kept
226226
expect(mockYargsParse).toBeCalledWith(['--keep1', '--keep2'])
227227
mockYargsParse.mockClear()
228228

229-
await runCommand('build:electron', {}, {}, [...args, '--keep2'])
229+
await runCommand('electron:build', {}, {}, [...args, '--keep2'])
230230
// Custom args should have been removed, and other args kept
231231
expect(mockYargsParse).toBeCalledWith(['--keep2'])
232232
mockYargsParse.mockClear()
233233

234-
await runCommand('build:electron', {}, {}, ['--keep1', ...args])
234+
await runCommand('electron:build', {}, {}, ['--keep1', ...args])
235235
// Custom args should have been removed, and other args kept
236236
expect(mockYargsParse).toBeCalledWith(['--keep1'])
237237
mockYargsParse.mockClear()
238238

239-
await runCommand('build:electron', {}, {}, args)
239+
await runCommand('electron:build', {}, {}, args)
240240
// Custom args should have been removed
241241
expect(mockYargsParse).toBeCalledWith([])
242242
mockYargsParse.mockClear()
243243

244-
await runCommand('build:electron', {}, {}, ['--keep1', '--keep2'])
244+
await runCommand('electron:build', {}, {}, ['--keep1', '--keep2'])
245245
// Nothing should be removed
246246
expect(mockYargsParse).toBeCalledWith(['--keep1', '--keep2'])
247247
})
248248

249249
test('Modern mode is enabled by default', async () => {
250-
await runCommand('build:electron')
250+
await runCommand('electron:build')
251251
expect(serviceRun.mock.calls[0][1].modern).toBe(true)
252252
})
253253

254254
test('Modern mode is disabled if --legacy arg is passed', async () => {
255-
await runCommand('build:electron', {}, { legacy: true })
255+
await runCommand('electron:build', {}, { legacy: true })
256256
expect(serviceRun.mock.calls[0][1].modern).toBe(false)
257257
})
258258

259259
test('App is not bundled if --skipBundle arg is passed', async () => {
260-
await runCommand('build:electron', {}, { skipBundle: true })
260+
await runCommand('electron:build', {}, { skipBundle: true })
261261
expect(serviceRun).not.toBeCalled()
262262
expect(webpack).not.toBeCalled()
263263
})
264264

265265
test('Env vars prefixed with VUE_APP_ are available in main process config', async () => {
266266
process.env.VUE_APP_TEST = 'expected'
267-
await runCommand('serve:electron')
267+
await runCommand('electron:serve')
268268
const mainConfig = webpack.mock.calls[0][0]
269269
// Env var is set correctly
270270
expect(mainConfig.plugins[1].defaultValues.VUE_APP_TEST).toBe('expected')
271271
})
272272
})
273273

274-
describe('serve:electron', () => {
274+
describe('electron:serve', () => {
275275
process.env.NODE_ENV = 'development'
276276

277277
test('typescript is disabled when set in options', async () => {
278-
await runCommand('serve:electron', {
278+
await runCommand('electron:serve', {
279279
pluginOptions: {
280280
electronBuilder: {
281281
disableMainProcessTypescript: true
@@ -295,7 +295,7 @@ describe('serve:electron', () => {
295295
})
296296

297297
test('custom background file is used if provided', async () => {
298-
await runCommand('serve:electron', {
298+
await runCommand('electron:serve', {
299299
pluginOptions: {
300300
electronBuilder: {
301301
mainProcessFile: 'customBackground.js'
@@ -311,7 +311,7 @@ describe('serve:electron', () => {
311311
})
312312

313313
test('custom output dir is used if set in vue.config.js', async () => {
314-
await runCommand('serve:electron', {
314+
await runCommand('electron:serve', {
315315
pluginOptions: {
316316
electronBuilder: {
317317
outputDir: 'output'
@@ -325,7 +325,7 @@ describe('serve:electron', () => {
325325
})
326326

327327
test('Custom main process webpack config is used if provided', async () => {
328-
await runCommand('serve:electron', {
328+
await runCommand('electron:serve', {
329329
pluginOptions: {
330330
electronBuilder: {
331331
chainWebpackMainProcess: config => {
@@ -341,12 +341,12 @@ describe('serve:electron', () => {
341341
})
342342

343343
test('process.env.IS_ELECTRON is set to true', async () => {
344-
await runCommand('serve:electron')
344+
await runCommand('electron:serve')
345345
expect(process.env.IS_ELECTRON).toBe('true')
346346
})
347347

348348
test('If --debug argument is passed, electron is not launched, main process is not minified, and source maps are enabled', async () => {
349-
await runCommand('serve:electron', {}, { debug: true })
349+
await runCommand('electron:serve', {}, { debug: true })
350350
const mainConfig = webpack.mock.calls[0][0]
351351

352352
// UglifyJS plugin does not exist
@@ -362,7 +362,7 @@ describe('serve:electron', () => {
362362
})
363363

364364
test('.js and .ts are merged into file extensions', async () => {
365-
await runCommand('serve:electron')
365+
await runCommand('electron:serve')
366366

367367
const mainConfig = webpack.mock.calls[0][0]
368368
// Both .js and .ts are resolved
@@ -377,7 +377,7 @@ describe('serve:electron', () => {
377377
// Set callback to be called later
378378
watchCb = cb
379379
})
380-
await runCommand('serve:electron', {
380+
await runCommand('electron:serve', {
381381
pluginOptions: {
382382
electronBuilder: {
383383
// Make sure it watches proper background file
@@ -416,7 +416,7 @@ describe('serve:electron', () => {
416416
// Set callback to be called later
417417
watchCb[file] = cb
418418
})
419-
await runCommand('serve:electron', {
419+
await runCommand('electron:serve', {
420420
pluginOptions: {
421421
electronBuilder: {
422422
// Make sure background file is watch as well
@@ -463,7 +463,7 @@ describe('serve:electron', () => {
463463
})
464464

465465
test('Junk output is stripped from electron child process', async () => {
466-
await runCommand('serve:electron')
466+
await runCommand('electron:serve')
467467

468468
// Junk is removed
469469
expect(mockExeca.stderr.pipe).toBeCalledWith('removeJunk')
@@ -474,7 +474,7 @@ describe('serve:electron', () => {
474474
})
475475

476476
test('Junk output is not stripped from electron child process if removeElectronJunk is set to false', async () => {
477-
await runCommand('serve:electron', {
477+
await runCommand('electron:serve', {
478478
pluginOptions: { electronBuilder: { removeElectronJunk: false } }
479479
})
480480

@@ -487,7 +487,7 @@ describe('serve:electron', () => {
487487
})
488488

489489
test('package.json is copied', async () => {
490-
await runCommand('serve:electron', {
490+
await runCommand('electron:serve', {
491491
pluginOptions: { electronBuilder: { outputDir: 'outputDir' } }
492492
})
493493

@@ -526,7 +526,7 @@ describe('Custom webpack chain', () => {
526526

527527
test('Env vars prefixed with VUE_APP_ are available in main process config', async () => {
528528
process.env.VUE_APP_TEST = 'expected'
529-
await runCommand('serve:electron')
529+
await runCommand('electron:serve')
530530
const mainConfig = webpack.mock.calls[0][0]
531531
// Env var is set correctly
532532
expect(mainConfig.plugins[1].defaultValues.VUE_APP_TEST).toBe('expected')
@@ -551,7 +551,7 @@ describe('testWithSpectron', async () => {
551551
}
552552
})
553553
const testPromise = testWithSpectron(spectronOptions)
554-
// Mock console.log from serve:electron
554+
// Mock console.log from electron:serve
555555
if (launchOptions.customLog) await sendData(launchOptions.customLog)
556556
await sendData(`$outputDir=${launchOptions.outputDir || 'dist_electron'}`)
557557
await sendData(

__tests__/serve.helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ portfinder.basePort = 9515
99
const serve = (project, notifyUpdate) =>
1010
new Promise((resolve, reject) => {
1111
// --debug to prevent Electron from being launched
12-
const child = project.run('vue-cli-service serve:electron --debug')
12+
const child = project.run('vue-cli-service electron:serve --debug')
1313
let log = ''
1414
child.stdout.on('data', async data => {
1515
data = data.toString()

__tests__/serve.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
jest.setTimeout(100000)
22

33
const runTests = require('./serve.helper.js').runTests
4-
test('serve:electron', async () => {
4+
test('electron:serve', async () => {
55
await runTests()
66
})

__tests__/serveTS.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
jest.setTimeout(100000)
22

33
const runTests = require('./serve.helper.js').runTests
4-
test('serve:electron-ts', async () => {
4+
test('electron:serve-ts', async () => {
55
await runTests(true)
66
})

__tests__/webpackConfig.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('chainWebpack', () => {
5656
})
5757

5858
test('process.env.VUE_APP_NODE_MODULES_PATH is set to projectPath/node_modules in Electron dev', () => {
59-
// Simulate serve:electron
59+
// Simulate electron:serve
6060
process.env.NODE_ENV = 'development'
6161
mockChain()
6262
// Is set to project's node_modules folder

docs/guide/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ That's It! You're ready to go!
2727

2828
If you use [Yarn](https://yarnpkg.com/en/) (strongly recommended):
2929

30-
`yarn serve:electron`
30+
`yarn electron:serve`
3131

3232
or if you use NPM:
3333

34-
`npm run serve:electron`
34+
`npm run electron:serve`
3535

3636
## To Build Your App
3737

3838
With Yarn:
3939

40-
`yarn build:electron`
40+
`yarn electron:build`
4141

4242
or with NPM:
4343

44-
`npm run build:electron`
44+
`npm run electron:build`

0 commit comments

Comments
 (0)