Skip to content

Commit

Permalink
Refactor default_app removal code
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Apr 10, 2018
1 parent fa2f482 commit e52490a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions platform.js
Expand Up @@ -83,19 +83,18 @@ class App {
* * Copies template into temporary directory
* * Copies user's app into temporary directory
* * Prunes non-production node_modules (if opts.prune is either truthy or undefined)
* * Remove default_app (which is either a folder or an asar file)
* * Creates an asar (if opts.asar is set)
*
* Prune and asar are performed before platform-specific logic, primarily so that
* this.originalResourcesAppDir is predictable (e.g. before .app is renamed for Mac)
*/
initialize () {
debug(`Initializing app in ${this.stagingPath} from ${this.templatePath} template`)

return fs.move(this.templatePath, this.stagingPath, { clobber: true })
.then(() => this.copyTemplate())
.then(() => {
// Support removing old default_app folder that is now an asar archive
return fs.remove(path.join(this.originalResourcesDir, 'default_app'))
}).then(() => fs.remove(path.join(this.originalResourcesDir, 'default_app.asar')))
// Prune and asar are performed before platform-specific logic, primarily so that
// this.originalResourcesAppDir is predictable (e.g. before .app is renamed for mac)
.then(() => this.removeDefaultApp())
.then(() => this.asarApp())
}

Expand All @@ -122,6 +121,11 @@ class App {
})
}

removeDefaultApp () {
return fs.remove(path.join(this.originalResourcesDir, 'default_app'))
.then(() => fs.remove(path.join(this.originalResourcesDir, 'default_app.asar')))
}

/**
* Forces an icon filename to a given extension and returns the normalized filename,
* if it exists. Otherwise, returns null.
Expand Down
4 changes: 2 additions & 2 deletions test/basic.js
Expand Up @@ -144,9 +144,9 @@ util.testSinglePlatform('defaults test', (t, opts) => {
t.true(equal, 'File under subdirectory of packaged app directory should match source file and not be ignored by default')
return fs.pathExists(path.join(resourcesPath, 'default_app'))
}).then(exists => {
t.false(exists, 'The output directory should not contain the Electron default app directory')
t.false(exists, 'The output directory should not contain the Electron default_app directory')
return fs.pathExists(path.join(resourcesPath, 'default_app.asar'))
}).then(exists => t.false(exists, 'The output directory should not contain the Electron default app asar file'))
}).then(exists => t.false(exists, 'The output directory should not contain the Electron default_app.asar file'))
})

util.testSinglePlatform('out test', (t, opts) => {
Expand Down

0 comments on commit e52490a

Please sign in to comment.