Skip to content

Commit

Permalink
fix: from as file and to as dir
Browse files Browse the repository at this point in the history
Close #1245
  • Loading branch information
develar committed Feb 14, 2017
1 parent bbc1df6 commit 3bb2ab8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/electron-builder/src/fileMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export function copyFiles(patterns: Array<FileMatcher> | null): Promise<any> {
}

if (fromStat.isFile()) {
const toStat = await statOrNull(pattern.to)
// https://github.com/electron-userland/electron-builder/issues/1245
if (toStat != null && toStat.isDirectory()) {
return await copyFile(pattern.from, path.join(pattern.to, path.basename(pattern.from)), fromStat)
}

await mkdirs(path.dirname(pattern.to))
return await copyFile(pattern.from, pattern.to, fromStat)
}
Expand Down
16 changes: 12 additions & 4 deletions test/src/filesTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,28 @@ test.ifDevOrLinuxCi("map resources", app({
targets: Platform.LINUX.createTarget(DIR_TARGET),
config: {
asar: false,
extraResources: {
from: "foo/old",
to: "foo/new",
},
extraResources: [
{
from: "foo/old",
to: "foo/new",
},
{
from: "license.txt",
to: ".",
},
],
}
}, {
projectDirCreated: projectDir => BluebirdPromise.all([
outputFile(path.join(projectDir, "foo", "old"), "data"),
outputFile(path.join(projectDir, "license.txt"), "data"),
]),
packed: context => {
const resources = path.join(context.getResources(Platform.LINUX))
return BluebirdPromise.all([
assertThat(path.join(resources, "app", "foo", "old")).doesNotExist(),
assertThat(path.join(resources, "foo", "new")).isFile(),
assertThat(path.join(resources, "license.txt")).isFile(),
])
},
}))
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,8 @@ glob@~5.0.0:
path-is-absolute "^1.0.0"

globals@^9.0.0:
version "9.14.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034"
version "9.15.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.15.0.tgz#7a5d8fd865e69de910b090b15a87772f9423c5de"

got@^5.0.0:
version "5.7.1"
Expand Down

0 comments on commit 3bb2ab8

Please sign in to comment.