diff --git a/packages/electron-builder/src/fileMatcher.ts b/packages/electron-builder/src/fileMatcher.ts index 8e1d4ed04ce..98f7ea88eb8 100644 --- a/packages/electron-builder/src/fileMatcher.ts +++ b/packages/electron-builder/src/fileMatcher.ts @@ -93,6 +93,12 @@ export function copyFiles(patterns: Array | null): Promise { } 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) } diff --git a/test/src/filesTest.ts b/test/src/filesTest.ts index 78587a3b583..95b533176ad 100644 --- a/test/src/filesTest.ts +++ b/test/src/filesTest.ts @@ -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(), ]) }, })) diff --git a/yarn.lock b/yarn.lock index 24fd7527ca8..1ddabad4a57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"