@synth1s/cloak 1.9.1 → 1.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/lib/setup.js +13 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synth1s/cloak",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "Cloak your Claude. Switch identities in seconds.",
5
5
  "type": "module",
6
6
  "bin": {
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 (isAlreadyInstalled(rcFilePath)) return
25
- const line = '\neval "$(cloak init)"\n'
26
- writeFileSync(rcFilePath, line, { flag: 'a' })
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
  }