Skip to content

Commit f5495f1

Browse files
committed
fix(build&serve): support --skip-plugins, fixes #1358
1 parent 3fdb0a2 commit f5495f1

File tree

2 files changed

+62
-55
lines changed

2 files changed

+62
-55
lines changed

__tests__/commands.spec.js

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ describe('electron:build', () => {
225225

226226
test.each([
227227
['--mode', 'someMode'],
228+
['--skip-plugins', 'somePlugin'],
228229
['--legacy'],
229230
['--dashboard'],
230231
['--skipBundle'],
@@ -376,11 +377,15 @@ describe('electron:build', () => {
376377

377378
expect(fs.writeFileSync).toBeCalledWith(
378379
'dist_electron/bundled/package.json',
379-
JSON.stringify({
380-
dependencies: {
381-
external: '^0.0.1'
382-
}
383-
}, undefined, 2)
380+
JSON.stringify(
381+
{
382+
dependencies: {
383+
external: '^0.0.1'
384+
}
385+
},
386+
undefined,
387+
2
388+
)
384389
)
385390
})
386391

@@ -811,54 +816,52 @@ describe('electron:serve', () => {
811816
)
812817
})
813818

814-
test.each([['--dashboard'], ['--debug'], ['--headless']])(
815-
'%s argument is not passed to electron',
816-
async (...args) => {
817-
await runCommand('electron:serve', {}, {}, [
818-
'--keep1',
819-
...args,
820-
'--keep2'
821-
])
822-
// Custom args should have been removed, and other args kept
823-
let calledArgs = execa.mock.calls[0][1]
824-
// Remove dist_electron
825-
calledArgs.shift()
826-
expect(calledArgs).toEqual(['--keep1', '--keep2'])
827-
execa.mockClear()
828-
829-
await runCommand('electron:serve', {}, {}, [...args, '--keep2'])
830-
// Custom args should have been removed, and other args kept
831-
calledArgs = execa.mock.calls[0][1]
832-
// Remove dist_electron
833-
calledArgs.shift()
834-
expect(calledArgs).toEqual(['--keep2'])
835-
execa.mockClear()
836-
837-
await runCommand('electron:serve', {}, {}, ['--keep1', ...args])
838-
// Custom args should have been removed, and other args kept
839-
calledArgs = execa.mock.calls[0][1]
840-
// Remove dist_electron
841-
calledArgs.shift()
842-
expect(calledArgs).toEqual(['--keep1'])
843-
execa.mockClear()
844-
845-
await runCommand('electron:serve', {}, {}, args)
846-
// Custom args should have been removed
847-
calledArgs = execa.mock.calls[0][1]
848-
// Remove dist_electron
849-
calledArgs.shift()
850-
expect(calledArgs).toEqual([])
851-
execa.mockClear()
852-
853-
await runCommand('electron:serve', {}, {}, ['--keep1', '--keep2'])
854-
// Nothing should be removed
855-
calledArgs = execa.mock.calls[0][1]
856-
// Remove dist_electron
857-
calledArgs.shift()
858-
expect(calledArgs).toEqual(['--keep1', '--keep2'])
859-
execa.mockClear()
860-
}
861-
)
819+
test.each([
820+
['--dashboard'],
821+
['--debug'],
822+
['--headless'],
823+
['--skip-plugins', 'somePlugin']
824+
])('%s argument is not passed to electron', async (...args) => {
825+
await runCommand('electron:serve', {}, {}, ['--keep1', ...args, '--keep2'])
826+
// Custom args should have been removed, and other args kept
827+
let calledArgs = execa.mock.calls[0][1]
828+
// Remove dist_electron
829+
calledArgs.shift()
830+
expect(calledArgs).toEqual(['--keep1', '--keep2'])
831+
execa.mockClear()
832+
833+
await runCommand('electron:serve', {}, {}, [...args, '--keep2'])
834+
// Custom args should have been removed, and other args kept
835+
calledArgs = execa.mock.calls[0][1]
836+
// Remove dist_electron
837+
calledArgs.shift()
838+
expect(calledArgs).toEqual(['--keep2'])
839+
execa.mockClear()
840+
841+
await runCommand('electron:serve', {}, {}, ['--keep1', ...args])
842+
// Custom args should have been removed, and other args kept
843+
calledArgs = execa.mock.calls[0][1]
844+
// Remove dist_electron
845+
calledArgs.shift()
846+
expect(calledArgs).toEqual(['--keep1'])
847+
execa.mockClear()
848+
849+
await runCommand('electron:serve', {}, {}, args)
850+
// Custom args should have been removed
851+
calledArgs = execa.mock.calls[0][1]
852+
// Remove dist_electron
853+
calledArgs.shift()
854+
expect(calledArgs).toEqual([])
855+
execa.mockClear()
856+
857+
await runCommand('electron:serve', {}, {}, ['--keep1', '--keep2'])
858+
// Nothing should be removed
859+
calledArgs = execa.mock.calls[0][1]
860+
// Remove dist_electron
861+
calledArgs.shift()
862+
expect(calledArgs).toEqual(['--keep1', '--keep2'])
863+
execa.mockClear()
864+
})
862865

863866
test('Electron is launched with arguments', async () => {
864867
await runCommand('electron:serve', {}, {}, ['--expected'])

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module.exports = (api, options) => {
7676
// Prevent custom args from interfering with electron-builder
7777
removeArg('--mode', 2, rawArgs)
7878
removeArg('--dest', 2, rawArgs)
79+
removeArg('--skip-plugins', 2, rawArgs)
7980
removeArg('--legacy', 1, rawArgs)
8081
removeArg('--dashboard', 1, rawArgs)
8182
removeArg('--skipBundle', 1, rawArgs)
@@ -115,7 +116,8 @@ module.exports = (api, options) => {
115116
modern: !args.legacy,
116117
// --report and --report-json args
117118
report: args.report,
118-
'report-json': args['report-json']
119+
'report-json': args['report-json'],
120+
skipPlugins: args.skipPlugins
119121
}
120122
// With @vue/cli-service v3.4.1+, we can bypass legacy build
121123
process.env.VUE_CLI_MODERN_BUILD = !args.legacy || ''
@@ -287,6 +289,7 @@ module.exports = (api, options) => {
287289
const mainProcessArgs = pluginOptions.mainProcessArgs || []
288290

289291
// Don't pass command args to electron
292+
removeArg('--skip-plugins', 2, rawArgs)
290293
removeArg('--dashboard', 1, rawArgs)
291294
removeArg('--debug', 1, rawArgs)
292295
removeArg('--headless', 1, rawArgs)
@@ -297,7 +300,8 @@ module.exports = (api, options) => {
297300
_: rendererProcessFile,
298301
// Use dashboard if called from ui
299302
dashboard: args.dashboard,
300-
https: args.https
303+
https: args.https,
304+
skipPlugins: args.skipPlugins
301305
})
302306
const outputDir = pluginOptions.outputDir || 'dist_electron'
303307

0 commit comments

Comments
 (0)