Skip to content

Commit

Permalink
fix: ignore node_modules without package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 14, 2017
1 parent c04dd20 commit 974dc6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/electron-builder-util/src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function exists(file: string): Promise<boolean> {
}
}

export async function walk(initialDirPath: string, filter?: Filter | null, consumer?: (file: string, stat: Stats, parent: string, extraIgnoredFiles: Set<string>) => any): Promise<Array<string>> {
export async function walk(initialDirPath: string, filter?: Filter | null, consumer?: (file: string, stat: Stats, parent: string, extraIgnoredFiles: Set<string>, siblingNames: Array<string>) => any): Promise<Array<string>> {
const result: Array<string> = []
const queue: Array<string> = [initialDirPath]
let addDirToResult = false
Expand All @@ -68,7 +68,7 @@ export async function walk(initialDirPath: string, filter?: Filter | null, consu
return null
}

const consumerResult = consumer == null ? null : consumer(filePath, stat, dirPath, extraIgnoredFiles)
const consumerResult = consumer == null ? null : consumer(filePath, stat, dirPath, extraIgnoredFiles, childNames)
if (consumerResult == null || !("then" in consumerResult)) {
if (stat.isDirectory()) {
dirs.push(name)
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/asarUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export class AsarPackager {
async pack(filter: Filter, isElectronCompile: boolean) {
const metadata = this.metadata
const nodeModulesSystemDependentSuffix = `${path.sep}node_modules`
let files = await walk(this.src, filter, (file, fileStat, parent, extraIgnoredFiles) => {
let files = await walk(this.src, filter, (file, fileStat, parent, extraIgnoredFiles, siblingNames) => {
metadata.set(file, fileStat)

// https://github.com/electron-userland/electron-builder/issues/1539
// but do not filter if we inside node_modules dir
if (fileStat.isDirectory() && file.endsWith(nodeModulesSystemDependentSuffix) && !parent.includes("node_modules")) {
if (fileStat.isDirectory() && file.endsWith(nodeModulesSystemDependentSuffix) && !parent.includes("node_modules") && siblingNames.includes("package.json")) {
return dependencies(parent, extraIgnoredFiles)
.then(it => {
if (debug.enabled) {
Expand Down

0 comments on commit 974dc6e

Please sign in to comment.