@synth1s/cloak 1.9.1 → 1.9.3
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/package.json +1 -1
- package/src/commands/switch.js +3 -2
- package/src/lib/setup.js +13 -3
package/package.json
CHANGED
package/src/commands/switch.js
CHANGED
|
@@ -14,14 +14,15 @@ export async function switchAccount(name, options = {}) {
|
|
|
14
14
|
|
|
15
15
|
if (!profileExists(name)) {
|
|
16
16
|
console.error(msg.accountNotFound(name))
|
|
17
|
-
console.
|
|
17
|
+
console.error(msg.suggestCreate(name))
|
|
18
18
|
process.exit(1)
|
|
19
19
|
return
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const active = getActiveProfile()
|
|
23
23
|
if (active === name) {
|
|
24
|
-
|
|
24
|
+
// Always stderr — stdout is reserved for eval-able output when --print-env
|
|
25
|
+
console.error(msg.alreadyWearing(name))
|
|
25
26
|
return
|
|
26
27
|
}
|
|
27
28
|
|
package/src/lib/setup.js
CHANGED
|
@@ -21,7 +21,17 @@ export function isAlreadyInstalled(rcFilePath) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function installToRcFile(rcFilePath) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (!existsSync(rcFilePath)) {
|
|
25
|
+
writeFileSync(rcFilePath, 'eval "$(cloak init)"\n')
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Read existing content and remove ALL lines containing 'cloak init'
|
|
30
|
+
const content = readFileSync(rcFilePath, 'utf8')
|
|
31
|
+
const lines = content.split('\n')
|
|
32
|
+
const cleaned = lines.filter(line => !line.includes('cloak init'))
|
|
33
|
+
const cleanedContent = cleaned.join('\n').replace(/\n{3,}/g, '\n\n')
|
|
34
|
+
|
|
35
|
+
// Write cleaned content + fresh init line
|
|
36
|
+
writeFileSync(rcFilePath, cleanedContent.trimEnd() + '\neval "$(cloak init)"\n')
|
|
27
37
|
}
|