Skip to content

Commit

Permalink
feat: Hidden 'dotfiles' within an extraResources folder aren't copied
Browse files Browse the repository at this point in the history
Closes #733
  • Loading branch information
develar committed Sep 10, 2016
1 parent b4aa52a commit 7877f71
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
10 changes: 9 additions & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ macOS only.
| Name | Description
| --- | ---
| **name** | <a name="Protocol-name"></a>The name. e.g. `IRC server URL`.
| role | <a name="Protocol-role"></a>*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`.
| **schemes** | <a name="Protocol-schemes"></a>The schemes. e.g. `["irc", "ircs"]`.

<a name="MetadataDirectories"></a>
Expand All @@ -198,7 +199,14 @@ macOS only.

# File Patterns

[build.files](#BuildMetadata-files) defaults to `**/*` (i.e. [hidden files are ignored by default](https://www.npmjs.com/package/glob#dots)).
[build.files](#BuildMetadata-files) defaults to:
* `**/*`
* `!**/node_modules/*/{README.md,README,readme.md,readme,test}`
* `!**/node_modules/.bin`
* `!**/*.{o,hprof,orig,pyc,pyo,rbc}`
* `!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db}`

[Hidden files are not ignored by default](https://www.npmjs.com/package/glob#dots), but as you see, all files that should be ignored, are ignored by default.

Development dependencies are never copied in any case. You don't need to ignore it explicitly.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"cli-cursor": "^1.0.2",
"cuint": "^0.2.2",
"debug": "^2.2.0",
"electron-download": "^2.1.2",
"electron-download": "2.1.2",
"electron-osx-sign": "^0.4.0-beta4",
"extract-zip": "^1.5.0",
"fs-extra-p": "^1.1.8",
Expand Down Expand Up @@ -121,7 +121,7 @@
"json8": "^0.9.2",
"path-sort": "^0.1.0",
"pre-git": "^3.10.0",
"ts-babel": "^1.0.6",
"ts-babel": "^1.0.7",
"tslint": "^3.15.1",
"typescript": "^2.0.2",
"whitespace": "^2.1.0"
Expand Down
5 changes: 3 additions & 2 deletions src/fileMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class FileMatcher {
}

getParsedPatterns(fromDir?: string): Array<Minimatch> {
const minimatchOptions = {}
// https://github.com/electron-userland/electron-builder/issues/733
const minimatchOptions = {dot: true}

const parsedPatterns: Array<Minimatch> = []
const pathDifference = fromDir ? path.relative(fromDir, this.from) : null
Expand Down Expand Up @@ -67,7 +68,7 @@ export class FileMatcher {
return pattern
.replace(/\$\{arch}/g, this.options.arch)
.replace(/\$\{os}/g, this.options.os)
.replace(/\$\{\/\*}/g, "{,/**/*,/**/.*}")
.replace(/\$\{\/\*}/g, "{,/**/*}")
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
defaultMatcher.addPattern("**/*")
}
defaultMatcher.addPattern("!**/node_modules/*/{README.md,README,readme.md,readme,test}")
defaultMatcher.addPattern("!**/node_modules/.bin")
defaultMatcher.addPattern("!**/*.{o,hprof,orig,pyc,pyo,rbc}")
defaultMatcher.addPattern("!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db}")

let rawFilter: any = null
const deprecatedIgnore = (<any>this.devMetadata.build).ignore
Expand Down
28 changes: 24 additions & 4 deletions test/src/globTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ test.ifDevOrLinuxCi("ignore build resources", app({
},
}))

test.ifDevOrLinuxCi("ignore known ignored files", app({
targets: Platform.LINUX.createTarget(DIR_TARGET),
devMetadata: {
build: {
asar: false
}
}
}, {
projectDirCreated: projectDir => BluebirdPromise.all([
outputFile(path.join(projectDir, ".svn", "foo"), "data"),
outputFile(path.join(projectDir, ".git", "foo"), "data"),
outputFile(path.join(projectDir, "foo", "bar", "f.o"), "data"),
outputFile(path.join(projectDir, "node_modules", ".bin", "f.txt"), "data"),
outputFile(path.join(projectDir, "node_modules", ".bin2", "f.txt"), "data"),
]),
packed: async context => {
await assertThat(path.join(context.getResources(Platform.LINUX), "app", ".svn")).doesNotExist()
await assertThat(path.join(context.getResources(Platform.LINUX), "app", ".git")).doesNotExist()
await assertThat(path.join(context.getResources(Platform.LINUX), "app", "foo", "bar", "f.o")).doesNotExist()
await assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", ".bin")).doesNotExist()
await assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", ".bin2")).isDirectory()
},
}))

test.ifDevOrLinuxCi("files", app({
targets: Platform.LINUX.createTarget(DIR_TARGET),
devMetadata: {
Expand Down Expand Up @@ -192,7 +216,6 @@ test("extraResources", async () => {
}),
outputFile(path.join(projectDir, "foo/nameWithoutDot"), "nameWithoutDot"),
outputFile(path.join(projectDir, "bar/hello.txt"), "data"),
outputFile(path.join(projectDir, "foo", ".dot"), "data"),
outputFile(path.join(projectDir, `bar/${process.arch}.txt`), "data"),
outputFile(path.join(projectDir, `${osName}/${process.arch}.txt`), "data"),
outputFile(path.join(projectDir, "platformSpecificR"), "platformSpecificR"),
Expand All @@ -212,7 +235,6 @@ test("extraResources", async () => {
await assertThat(path.join(resourcesDir, osName, `${process.arch}.txt`)).isFile()
await assertThat(path.join(resourcesDir, "platformSpecificR")).isFile()
await assertThat(path.join(resourcesDir, "ignoreMe.txt")).doesNotExist()
await assertThat(path.join(resourcesDir, "foo", ".dot")).doesNotExist()
},
expectedContents: platform === Platform.WINDOWS ? pathSorter(expectedWinContents.concat(
winDirPrefix + "bar/hello.txt",
Expand Down Expand Up @@ -262,7 +284,6 @@ test("extraResources - one-package", async () => {
}),
outputFile(path.join(projectDir, "foo/nameWithoutDot"), "nameWithoutDot"),
outputFile(path.join(projectDir, "bar/hello.txt"), "data"),
outputFile(path.join(projectDir, "foo", ".dot"), "data"),
outputFile(path.join(projectDir, `bar/${process.arch}.txt`), "data"),
outputFile(path.join(projectDir, `${osName}/${process.arch}.txt`), "data"),
outputFile(path.join(projectDir, "platformSpecificR"), "platformSpecificR"),
Expand Down Expand Up @@ -290,7 +311,6 @@ test("extraResources - one-package", async () => {
await assertThat(path.join(resourcesDir, osName, `${process.arch}.txt`)).isFile()
await assertThat(path.join(resourcesDir, "platformSpecificR")).isFile()
await assertThat(path.join(resourcesDir, "ignoreMe.txt")).doesNotExist()
await assertThat(path.join(resourcesDir, "foo", ".dot")).doesNotExist()
},
expectedContents: platform === Platform.WINDOWS ? pathSorter(expectedWinContents.concat(
winDirPrefix + "bar/hello.txt",
Expand Down

0 comments on commit 7877f71

Please sign in to comment.