@getbastionai/gatepost 1.0.3 → 1.0.5
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/setup.js +20 -12
package/package.json
CHANGED
package/src/setup.js
CHANGED
|
@@ -35,14 +35,18 @@ function setup() {
|
|
|
35
35
|
|
|
36
36
|
let updated = 0
|
|
37
37
|
for (const config of configs) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
try {
|
|
39
|
+
const contents = fs.readFileSync(config, 'utf8')
|
|
40
|
+
if (contents.includes(MARKER_START)) {
|
|
41
|
+
console.log(` Already configured: ${config}`)
|
|
42
|
+
continue
|
|
43
|
+
}
|
|
44
|
+
fs.appendFileSync(config, block)
|
|
45
|
+
console.log(` Updated: ${config}`)
|
|
46
|
+
updated++
|
|
47
|
+
} catch (e) {
|
|
48
|
+
// skip files we can't read or write
|
|
42
49
|
}
|
|
43
|
-
fs.appendFileSync(config, block)
|
|
44
|
-
console.log(` Updated: ${config}`)
|
|
45
|
-
updated++
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
if (updated > 0) {
|
|
@@ -58,11 +62,15 @@ function remove() {
|
|
|
58
62
|
|
|
59
63
|
let removed = 0
|
|
60
64
|
for (const config of configs) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
try {
|
|
66
|
+
const contents = fs.readFileSync(config, 'utf8')
|
|
67
|
+
if (!contents.includes(MARKER_START)) continue
|
|
68
|
+
fs.writeFileSync(config, contents.replace(re, '\n'))
|
|
69
|
+
console.log(` Removed aliases from: ${config}`)
|
|
70
|
+
removed++
|
|
71
|
+
} catch (e) {
|
|
72
|
+
// skip files we can't read or write
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
if (removed === 0) {
|