@starlove/orbit 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full/version.json +2 -2
- package/package.json +1 -1
- package/src/core/system-picker.js +31 -15
package/dist/full/version.json
CHANGED
package/package.json
CHANGED
|
@@ -6,6 +6,21 @@ const execFileAsync = promisify(execFile);
|
|
|
6
6
|
|
|
7
7
|
const DEFAULT_TITLE = "Choose repo folder for Orbit board";
|
|
8
8
|
|
|
9
|
+
const WINDOWS_FOLDER_PICKER_ARGS = (title) => [
|
|
10
|
+
"-NoProfile",
|
|
11
|
+
"-STA",
|
|
12
|
+
"-Command",
|
|
13
|
+
[
|
|
14
|
+
"Add-Type -AssemblyName System.Windows.Forms",
|
|
15
|
+
"$dialog = New-Object System.Windows.Forms.FolderBrowserDialog",
|
|
16
|
+
`$dialog.Description = ${JSON.stringify(title)}`,
|
|
17
|
+
"if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {",
|
|
18
|
+
" [Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
19
|
+
" Write-Output $dialog.SelectedPath",
|
|
20
|
+
"}"
|
|
21
|
+
].join("; ")
|
|
22
|
+
];
|
|
23
|
+
|
|
9
24
|
export function folderPickerCommands(platform = process.platform, title = DEFAULT_TITLE) {
|
|
10
25
|
if (platform === "darwin") {
|
|
11
26
|
return [
|
|
@@ -20,20 +35,7 @@ export function folderPickerCommands(platform = process.platform, title = DEFAUL
|
|
|
20
35
|
return [
|
|
21
36
|
{
|
|
22
37
|
command: "powershell.exe",
|
|
23
|
-
args:
|
|
24
|
-
"-NoProfile",
|
|
25
|
-
"-STA",
|
|
26
|
-
"-Command",
|
|
27
|
-
[
|
|
28
|
-
"Add-Type -AssemblyName System.Windows.Forms",
|
|
29
|
-
"$dialog = New-Object System.Windows.Forms.FolderBrowserDialog",
|
|
30
|
-
`$dialog.Description = ${JSON.stringify(title)}`,
|
|
31
|
-
"if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {",
|
|
32
|
-
" [Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
33
|
-
" Write-Output $dialog.SelectedPath",
|
|
34
|
-
"}"
|
|
35
|
-
].join("; ")
|
|
36
|
-
]
|
|
38
|
+
args: WINDOWS_FOLDER_PICKER_ARGS(title)
|
|
37
39
|
}
|
|
38
40
|
];
|
|
39
41
|
}
|
|
@@ -46,6 +48,10 @@ export function folderPickerCommands(platform = process.platform, title = DEFAUL
|
|
|
46
48
|
{
|
|
47
49
|
command: "kdialog",
|
|
48
50
|
args: ["--getexistingdirectory", ".", title]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
command: "powershell.exe",
|
|
54
|
+
args: WINDOWS_FOLDER_PICKER_ARGS(title)
|
|
49
55
|
}
|
|
50
56
|
];
|
|
51
57
|
}
|
|
@@ -59,6 +65,15 @@ function isPickerCancel(error) {
|
|
|
59
65
|
return error?.code === 1 && /cancel|user canceled|user cancelled/i.test(stderr);
|
|
60
66
|
}
|
|
61
67
|
|
|
68
|
+
function windowsPathToWslPath(rawPath) {
|
|
69
|
+
const path = String(rawPath || "").trim();
|
|
70
|
+
const drivePath = path.match(/^([a-zA-Z]):[\\/](.*)$/);
|
|
71
|
+
if (!drivePath) return path;
|
|
72
|
+
const drive = drivePath[1].toLowerCase();
|
|
73
|
+
const rest = drivePath[2].replace(/\\/g, "/").replace(/^\/+/, "");
|
|
74
|
+
return `/mnt/${drive}/${rest}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
export async function pickFolder(options = {}) {
|
|
63
78
|
const platform = options.platform || process.platform;
|
|
64
79
|
const title = options.title || DEFAULT_TITLE;
|
|
@@ -73,7 +88,8 @@ export async function pickFolder(options = {}) {
|
|
|
73
88
|
timeout: 120000,
|
|
74
89
|
windowsHide: false
|
|
75
90
|
});
|
|
76
|
-
const
|
|
91
|
+
const rawPath = String(result.stdout || "").trim();
|
|
92
|
+
const selectedPath = normalizePath(platform === "linux" && spec.command === "powershell.exe" ? windowsPathToWslPath(rawPath) : rawPath);
|
|
77
93
|
return selectedPath ? { path: selectedPath } : { canceled: true };
|
|
78
94
|
} catch (error) {
|
|
79
95
|
if (isMissingCommand(error)) {
|