Skip to content

Commit 5ae69d4

Browse files
nklaymanthislooksfun
authored andcommitted
fix(build): remove font duplication, fixes nklayman#694
1 parent 833deac commit 5ae69d4

File tree

2 files changed

+29
-50
lines changed

2 files changed

+29
-50
lines changed

__tests__/commands.spec.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,6 @@ describe('electron:build', () => {
215215
expect(builder.build.mock.calls[0][0].config.shouldBe).toBe('expected')
216216
})
217217

218-
test('Fonts folder is copied to css if it exists', async () => {
219-
// Mock existence of fonts folder
220-
fs.existsSync.mockReturnValueOnce(true)
221-
await runCommand('electron:build')
222-
// css/fonts folder was created
223-
expect(fs.ensureDirSync).toBeCalledWith(
224-
'projectPath/dist_electron/bundled/css/fonts'
225-
)
226-
// fonts was copied to css/fonts
227-
expect(fs.copySync).toBeCalledWith(
228-
'projectPath/dist_electron/bundled/fonts',
229-
'projectPath/dist_electron/bundled/css/fonts'
230-
)
231-
})
232-
233218
test('.js and .ts are merged into file extensions', async () => {
234219
await runCommand('electron:build')
235220

index.js

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,6 @@ module.exports = (api, options) => {
159159
)
160160
// Prevent electron-builder from installing app deps
161161
fs.ensureDirSync(`${outputDir}/bundled/node_modules`)
162-
// Copy fonts to css/fonts. Fixes some issues with static font imports
163-
if (fs.existsSync(api.resolve(outputDir + '/bundled/fonts'))) {
164-
fs.ensureDirSync(api.resolve(outputDir + '/bundled/css/fonts'))
165-
fs.copySync(
166-
api.resolve(outputDir + '/bundled/fonts'),
167-
api.resolve(outputDir + '/bundled/css/fonts')
168-
)
169-
}
170162

171163
if (bundleMainProcess) {
172164
// Build the main process into the renderer process output dir
@@ -210,7 +202,7 @@ module.exports = (api, options) => {
210202
buildApp()
211203
}
212204
}
213-
function buildApp () {
205+
function buildApp() {
214206
info('Building app with electron-builder:')
215207
// Build the app using electron builder
216208
builder
@@ -319,31 +311,32 @@ module.exports = (api, options) => {
319311
let child
320312
let firstBundleCompleted = false
321313
// Function to kill Electron process
322-
const killElectron = () => new Promise(resolve => {
323-
if (!child || child.killed) {
324-
return resolve()
325-
}
326-
327-
const currentChild = child
328-
currentChild.on('exit', () => {
329-
resolve()
330-
})
314+
const killElectron = () =>
315+
new Promise(resolve => {
316+
if (!child || child.killed) {
317+
return resolve()
318+
}
331319

332-
// Attempt to kill gracefully
333-
if (process.platform === 'win32') {
334-
currentChild.send('graceful-exit')
335-
} else {
336-
currentChild.kill('SIGTERM')
337-
}
320+
const currentChild = child
321+
currentChild.on('exit', () => {
322+
resolve()
323+
})
338324

339-
// Kill unconditionally after 2 seconds if unsuccessful
340-
setTimeout(() => {
341-
if (!currentChild.killed) {
342-
warn(`Force killing Electron (process #${currentChild.pid})`)
343-
currentChild.kill('SIGKILL')
325+
// Attempt to kill gracefully
326+
if (process.platform === 'win32') {
327+
currentChild.send('graceful-exit')
328+
} else {
329+
currentChild.kill('SIGTERM')
344330
}
345-
}, 2000)
346-
})
331+
332+
// Kill unconditionally after 2 seconds if unsuccessful
333+
setTimeout(() => {
334+
if (!currentChild.killed) {
335+
warn(`Force killing Electron (process #${currentChild.pid})`)
336+
currentChild.kill('SIGKILL')
337+
}
338+
}, 2000)
339+
})
347340

348341
// Initial start of Electron
349342
startElectron()
@@ -382,7 +375,7 @@ module.exports = (api, options) => {
382375
})
383376
}
384377

385-
async function launchElectron () {
378+
async function launchElectron() {
386379
firstBundleCompleted = true
387380
// Don't exit process when electron is killed
388381
if (child) {
@@ -472,7 +465,7 @@ module.exports = (api, options) => {
472465
}
473466
}
474467

475-
function onChildExit () {
468+
function onChildExit() {
476469
process.exit(0)
477470
}
478471
}
@@ -518,7 +511,7 @@ module.exports = (api, options) => {
518511
)
519512
}
520513

521-
function bundleMain ({
514+
function bundleMain({
522515
mode,
523516
api,
524517
args,
@@ -570,7 +563,8 @@ function bundleMain ({
570563
}
571564
})
572565
// Enable/disable nodeIntegration
573-
envVars.ELECTRON_NODE_INTEGRATION = args.headless || pluginOptions.nodeIntegration || false
566+
envVars.ELECTRON_NODE_INTEGRATION =
567+
args.headless || pluginOptions.nodeIntegration || false
574568
config.plugin('env').use(webpack.EnvironmentPlugin, [envVars])
575569

576570
if (args.debug) {

0 commit comments

Comments
 (0)