Skip to content

Commit 09a122d

Browse files
committed
🐛 Fix name compatibility
1 parent 72652d8 commit 09a122d

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

CLAUDE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ npm run build:mac # macOS universal build
7979

8080
### CLI Tool (`bin/`)
8181

82-
- `bin/cli.ts` - Main entry point
83-
- `bin/builders/` - Platform-specific builders
84-
- `bin/options/` - Configuration processing
82+
- `bin/cli.ts` - Main entry point with Commander.js
83+
- `bin/builders/` - Platform-specific builders (Mac, Windows, Linux)
84+
- `bin/options/` - CLI option processing and validation
85+
- `bin/helpers/merge.ts` - Configuration merging (name setting at line 55)
8586

8687
### Tauri Application (`src-tauri/`)
8788

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ pake url [OPTIONS]...
173173
# Feel free to play with Pake! It might take a while to prepare the environment the first time you launch Pake.
174174
pake https://weekly.tw93.fun --name Weekly --hide-title-bar
175175

176+
# Also supports names with spaces (cross-platform compatible)
177+
pake https://translate.google.com --name "Google Translate" --hide-title-bar
178+
176179
```
177180

178181
If you are new to the command line, you can compile packages online with _GitHub Actions_. See the [Tutorial](<https://github.com/tw93/Pake/wiki/Online-Compilation-(used-by-ordinary-users)>) for more information.

bin/README_CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ pake [url] [options]
6161

6262
指定应用程序的名称,如果未指定,系统会提示您输入,建议使用英文单词。
6363

64-
**注意**: 也支持多个单词,会自动处理不同平台的命名规范:
64+
**注意**: 支持带空格的名称,会自动处理不同平台的命名规范:
6565

6666
- **Windows/macOS**: 保持空格和大小写(如 `"Google Translate"`
67-
- **Linux**: 转换为小写并用连字符连接(如 `"google-translate"`
67+
- **Linux**: 自动转换为小写并用连字符连接(如 `"google-translate"`
6868

6969
```shell
7070
--name <string>
7171
--name MyApp
7272

73-
# 多个单词(如需要):
73+
# 带空格的名称:
7474
--name "Google Translate"
7575
```
7676

bin/cli.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ program
3131
// Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with custom connectors.
3232
// If the platform is Linux, use `-` as the connector, and convert all characters to lowercase.
3333
// For example, Google Translate will become google-translate.
34-
.option('--name <string...>', 'Application name', (value, previous) => {
35-
const platform = process.platform;
36-
const connector = platform === 'linux' ? '-' : ' ';
37-
const name =
38-
previous === undefined ? value : `${previous}${connector}${value}`;
39-
40-
return platform === 'linux' ? name.toLowerCase() : name;
41-
})
34+
.option('--name <string>', 'Application name')
4235
.option('--icon <string>', 'Application icon', DEFAULT.icon)
4336
.option(
4437
'--width <number>',

bin/options/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export default async function handleOptions(
3636
name = namePrompt || defaultName;
3737
}
3838

39+
// Handle platform-specific name formatting
40+
if (name && platform === 'linux') {
41+
// Convert to lowercase and replace spaces with dashes for Linux
42+
name = name.toLowerCase().replace(/\s+/g, '-');
43+
}
44+
3945
if (!isValidName(name, platform)) {
4046
const LINUX_NAME_ERROR = `✕ Name should only include lowercase letters, numbers, and dashes (not leading dashes). Examples: com-123-xxx, 123pan, pan123, weread, we-read, 123.`;
4147
const DEFAULT_NAME_ERROR = `✕ Name should only include letters, numbers, dashes, and spaces (not leading dashes and spaces). Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read, 123.`;

0 commit comments

Comments
 (0)