Skip to content

Commit

Permalink
fix: ignore node_modules without package.json
Browse files Browse the repository at this point in the history
Close #1671
  • Loading branch information
develar committed Jun 14, 2017
1 parent c04dd20 commit 5e24859
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"electron-download-tf": "4.3.1",
"electron-is-dev": "^0.1.2",
"electron-osx-sign": "0.4.6",
"fcopy-pre-bundled": "0.3.1",
"fcopy-pre-bundled": "0.3.3",
"fs-extra-p": "^4.3.0",
"hosted-git-info": "^2.4.2",
"ini": "^1.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"dependencies": {
"fs-extra-p": "^4.3.0",
"fcopy-pre-bundled": "0.3.1",
"fcopy-pre-bundled": "0.3.3",
"is-ci": "^1.0.10",
"stat-mode": "^0.2.2",
"bluebird-lst": "^1.0.2",
Expand Down
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
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1227,9 +1227,9 @@ fb-watchman@^2.0.0:
dependencies:
bser "^2.0.0"

[email protected].1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/fcopy-pre-bundled/-/fcopy-pre-bundled-0.3.1.tgz#d7c5a171850a92cedd5370abe50976b013b1ed8d"
[email protected].3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/fcopy-pre-bundled/-/fcopy-pre-bundled-0.3.3.tgz#4e1fce4a94ab3fafcf3bbb3d5567bb152092bf1b"

feature-detect-es6@^1.3.1:
version "1.3.1"
Expand Down

0 comments on commit 5e24859

Please sign in to comment.