Skip to content

Commit

Permalink
chore: make the name Linux-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
g1eny0ung committed Jan 3, 2025
1 parent 6a644ac commit 785c289
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 9 additions & 2 deletions bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ program.addHelpText('beforeAll', logo).usage(`[url] [options]`).showHelpAfterErr

program
.argument('[url]', 'The web URL you want to package', validateUrlInput)
// Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with custom connectors.
// If the platform is Linux, use `-` as the connector, and convert all characters to lowercase.
// For example, Google Translate will become google-translate.
.option('--name <string...>', 'Application name', (value, previous) => {
return previous === undefined ? value : `${previous} ${value}`
}) // Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with spaces.
const platform = process.platform
const connector = platform === 'linux' ? '-' : ' '
const name = previous === undefined ? value : `${previous}${connector}${value}`

return platform === 'linux' ? name.toLowerCase() : name
})
.option('--icon <string>', 'Application icon', DEFAULT.icon)
.option('--width <number>', 'Window width', validateNumberInput, DEFAULT.width)
.option('--height <number>', 'Window height', validateNumberInput, DEFAULT.height)
Expand Down
10 changes: 8 additions & 2 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,15 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
program.addHelpText('beforeAll', logo).usage(`[url] [options]`).showHelpAfterError();
program
.argument('[url]', 'The web URL you want to package', validateUrlInput)
// Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with custom connectors.
// If the platform is Linux, use `-` as the connector, and convert all characters to lowercase.
// For example, Google Translate will become google-translate.
.option('--name <string...>', 'Application name', (value, previous) => {
return previous === undefined ? value : `${previous} ${value}`;
}) // Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with spaces.
const platform = process.platform;
const connector = platform === 'linux' ? '-' : ' ';
const name = previous === undefined ? value : `${previous}${connector}${value}`;
return platform === 'linux' ? name.toLowerCase() : name;
})
.option('--icon <string>', 'Application icon', DEFAULT_PAKE_OPTIONS.icon)
.option('--width <number>', 'Window width', validateNumberInput, DEFAULT_PAKE_OPTIONS.width)
.option('--height <number>', 'Window height', validateNumberInput, DEFAULT_PAKE_OPTIONS.height)
Expand Down

0 comments on commit 785c289

Please sign in to comment.