diff --git a/src/common.js b/src/common.js index 1f6111ff..f51aff91 100644 --- a/src/common.js +++ b/src/common.js @@ -12,7 +12,7 @@ function sanitizeAppName (name) { } function generateFinalBasename (opts) { - return `${sanitizeAppName(opts.name)}-${opts.platform}-${opts.arch}` + return `${sanitizeAppName(opts.basename || opts.name)}-${opts.platform}-${opts.arch}` } function generateFinalPath (opts) { diff --git a/src/copy-filter.js b/src/copy-filter.js index ddfc6089..a24c1cac 100644 --- a/src/copy-filter.js +++ b/src/copy-filter.js @@ -40,6 +40,7 @@ function generateIgnoredOutDirs (opts) { for (const arch of archs) { const basenameOpts = { arch: arch, + basename: opts.basename, name: opts.name, platform: platform } diff --git a/src/index.d.ts b/src/index.d.ts index 5a2b63ed..19e7b6f7 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -463,6 +463,14 @@ declare namespace electronPackager { * **Note:** `junk` will have no effect if the {@link prebuiltAsar} option is set. */ junk?: boolean; + /** + * The base folder ${basename}-${platform}-${arch}. If omitted, it will use the `productName` or `name` value from the + * nearest `package.json`. + * + * **Regardless of source, characters in the Electron app name which are not allowed in all target + * platforms' filenames (e.g., `/`), will be replaced by hyphens (`-`).** + */ + basename?: string; /** * The application name. If omitted, it will use the `productName` or `name` value from the * nearest `package.json`. diff --git a/test/basic.js b/test/basic.js index 98934a2a..b3dd8f79 100644 --- a/test/basic.js +++ b/test/basic.js @@ -59,6 +59,16 @@ test('sanitize app name for use in the out directory name', t => { t.is(common.generateFinalBasename(opts), '@username-package-name-linux-x64', 'generateFinalBasename output should be sanitized') }) +test('basename should be used in the out directory name', t => { + const opts = { + arch: 'x64', + name: 'app name', + basename: 'myapp', + platform: 'linux' + } + t.is(common.generateFinalBasename(opts), 'myapp-linux-x64', 'generateFinalBasename output should use basename over name') +}) + test('cannot build apps where the name ends in " Helper"', async t => { const opts = { arch: 'x64',