Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basename option #1478

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/copy-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function generateIgnoredOutDirs (opts) {
for (const arch of archs) {
const basenameOpts = {
arch: arch,
basename: opts.basename,
name: opts.name,
platform: platform
}
Expand Down
8 changes: 8 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
10 changes: 10 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down