Skip to content

Commit

Permalink
refactor: cleanup doCopyExtraFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Aug 6, 2016
1 parent 06def89 commit d593a61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)",
"update-wiki": "git subtree split -b wiki --prefix docs/ && git push -f wiki wiki:master",
"whitespace": "whitespace src/**/*.ts",
"whitespace": "whitespace 'src/**/*.ts'",
"docker-images": "docker/build.sh"
},
"repository": {
Expand Down Expand Up @@ -124,7 +124,7 @@
"ts-babel": "^1.0.4",
"tslint": "3.14.0",
"typescript": "^2.1.0-dev.20160802",
"whitespace": "^2.0.0"
"whitespace": "^2.1.0"
},
"babel": {
"plugins": [
Expand Down
16 changes: 10 additions & 6 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
})
await task(`Packaging for platform ${platformName} ${Arch[arch]} using electron ${this.info.electronVersion} to ${path.relative(this.projectDir, appOutDir)}`, p)

await this.doCopyExtraFiles(true, appOutDir, arch, platformSpecificBuildOptions)
await this.doCopyExtraFiles(false, appOutDir, arch, platformSpecificBuildOptions)
await this.doCopyExtraFiles(true, appOutDir, extraResourcePatterns)
await this.doCopyExtraFiles(false, appOutDir, extraFilePatterns)

const afterPack = this.devMetadata.build.afterPack
if (afterPack != null) {
Expand Down Expand Up @@ -315,10 +315,14 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
.replace(/\$\{\/\*}/g, "{,/**/*,/**/.*}")
}

private async doCopyExtraFiles(isResources: boolean, appOutDir: string, arch: Arch, customBuildOptions: DC): Promise<any> {
const base = isResources ? this.getResourcesDir(appOutDir) : this.platform === Platform.MAC ? path.join(appOutDir, `${this.appInfo.productFilename}.app`, "Contents") : appOutDir
const patterns = this.getExtraFilePatterns(isResources, arch, customBuildOptions)
return patterns == null || patterns.length === 0 ? null : copyFiltered(this.projectDir, base, createFilter(this.projectDir, patterns), this.platform === Platform.WINDOWS)
private doCopyExtraFiles(isResources: boolean, appOutDir: string, patterns: Array<Minimatch> | null): Promise<any> {
const base = isResources ? this.getResourcesDir(appOutDir) : (this.platform === Platform.MAC ? path.join(appOutDir, `${this.appInfo.productFilename}.app`, "Contents") : appOutDir)
if (patterns == null || patterns.length === 0) {
return BluebirdPromise.resolve()
}
else {
return copyFiltered(this.projectDir, base, createFilter(this.projectDir, patterns), this.platform === Platform.WINDOWS)
}
}

private getParsedPatterns(patterns: Array<string>, arch: Arch): Array<Minimatch> {
Expand Down

0 comments on commit d593a61

Please sign in to comment.