editor-profile-sync 1.0.3 → 1.0.4
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/lib/editor-cli.js +20 -8
- package/package.json +1 -1
package/lib/editor-cli.js
CHANGED
|
@@ -59,14 +59,20 @@ export function getEditorCliPath(editor) {
|
|
|
59
59
|
const cmd = process.platform === "win32" ? "where" : "which";
|
|
60
60
|
try {
|
|
61
61
|
const result = execSync(`${cmd} ${editor.cmd}`, { encoding: "utf-8" });
|
|
62
|
-
|
|
62
|
+
const path = result.trim().split("\n")[0];
|
|
63
|
+
if (path) return path;
|
|
63
64
|
} catch {
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
// Fall through to fallback options
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// On macOS, fall back to app bundle path
|
|
69
|
+
if (process.platform === "darwin") {
|
|
70
|
+
const macPath = findMacOSCliPath(editor);
|
|
71
|
+
if (macPath) return macPath;
|
|
69
72
|
}
|
|
73
|
+
|
|
74
|
+
// Final fallback: use command name (should work if in PATH)
|
|
75
|
+
return editor.cmd;
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
function escapeShellArg(arg) {
|
|
@@ -77,7 +83,9 @@ function escapeShellArg(arg) {
|
|
|
77
83
|
function runEditorCmdAsync(editor, args, options = {}) {
|
|
78
84
|
const { ignoreError = false } = options;
|
|
79
85
|
const cliPath = getEditorCliPath(editor);
|
|
80
|
-
const cmdString = [cliPath, ...args.map(escapeShellArg)].join(
|
|
86
|
+
const cmdString = [escapeShellArg(cliPath), ...args.map(escapeShellArg)].join(
|
|
87
|
+
" ",
|
|
88
|
+
);
|
|
81
89
|
|
|
82
90
|
return new Promise((resolve, reject) => {
|
|
83
91
|
const child = spawn(cmdString, [], {
|
|
@@ -134,6 +142,10 @@ export async function installExtension(editor, extensionId) {
|
|
|
134
142
|
|
|
135
143
|
export function uninstallExtension(editor, extensionId) {
|
|
136
144
|
const cliPath = getEditorCliPath(editor);
|
|
137
|
-
const cmd = [
|
|
145
|
+
const cmd = [
|
|
146
|
+
escapeShellArg(cliPath),
|
|
147
|
+
"--uninstall-extension",
|
|
148
|
+
escapeShellArg(extensionId),
|
|
149
|
+
].join(" ");
|
|
138
150
|
execSync(cmd, { stdio: "ignore" });
|
|
139
151
|
}
|