Skip to content

Commit

Permalink
fix: Use of extraResources prevents node_modules from being included …
Browse files Browse the repository at this point in the history
…in asar

Close #867
  • Loading branch information
develar committed May 5, 2017
1 parent b0ce309 commit 0fbad33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/electron-builder/src/fileMatcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { FilePattern, PlatformSpecificBuildOptions } from "electron-builder-core"
import { asArray } from "electron-builder-util"
import { asArray, debug } from "electron-builder-util"
import { copyDir, copyFile, Filter, statOrNull } from "electron-builder-util/out/fs"
import { warn } from "electron-builder-util/out/log"
import { mkdirs } from "fs-extra-p"
Expand Down Expand Up @@ -80,6 +80,10 @@ export class FileMatcher {
this.computeParsedPatterns(parsedPatterns)
return createFilter(this.from, parsedPatterns, ignoreFiles, rawFilter, excludePatterns)
}

toString() {
return `from: ${this.from}, to: ${this.to}, patterns: ${this.patterns.join(", ")}`
}
}

export function createFileMatcher(info: BuildInfo, appDir: string, resourcesPath: string, macroExpander: (pattern: string) => string, platformSpecificBuildOptions: PlatformSpecificBuildOptions, buildResourceDir: string) {
Expand Down Expand Up @@ -190,6 +194,9 @@ export function copyFiles(patterns: Array<FileMatcher> | null): Promise<any> {
if (pattern.isEmpty() || pattern.containsOnlyIgnore()) {
pattern.addAllPattern()
}
if (debug.enabled) {
debug(`Copying files using pattern: ${pattern}`)
}
return await copyDir(pattern.from, pattern.to, pattern.createFilter())
})
}
5 changes: 3 additions & 2 deletions packages/electron-builder/src/util/filter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Filter } from "electron-builder-util/out/fs"
import { Stats } from "fs-extra-p"
import { Minimatch } from "minimatch"
import * as path from "path"
import { Filter } from "electron-builder-util/out/fs"

export function hasMagic(pattern: Minimatch) {
const set = pattern.set
Expand Down Expand Up @@ -38,7 +38,8 @@ export function createFilter(src: string, patterns: Array<Minimatch>, ignoreFile
relative = relative.replace(/\\/g, "/")
}

return minimatchAll(relative, patterns, stat) && (excludePatterns == null || !minimatchAll(relative, excludePatterns, stat))
// /~https://github.com/electron-userland/electron-builder/issues/867
return minimatchAll(relative, patterns, stat) && (excludePatterns == null || stat.isDirectory() || !minimatchAll(relative, excludePatterns, stat))
}
}

Expand Down

0 comments on commit 0fbad33

Please sign in to comment.