ramm 0.0.7 → 0.0.8
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/ramm.js +13 -1
- package/package.json +1 -1
package/dist/ramm.js
CHANGED
|
@@ -217,7 +217,7 @@ var addNftPodmanRule = async () => {
|
|
|
217
217
|
await execCommand(`nft add rule inet ramm forward iifname != @podman_interfaces jump ${localNftChainName}`);
|
|
218
218
|
};
|
|
219
219
|
// src/files.ts
|
|
220
|
-
import { appendFile } from "fs/promises";
|
|
220
|
+
import { appendFile, exists } from "fs/promises";
|
|
221
221
|
var finalizeWithNewline = (str) => {
|
|
222
222
|
if (str.at(-1) !== `
|
|
223
223
|
`) {
|
|
@@ -226,6 +226,14 @@ var finalizeWithNewline = (str) => {
|
|
|
226
226
|
}
|
|
227
227
|
return str;
|
|
228
228
|
};
|
|
229
|
+
var createDir = async (str) => {
|
|
230
|
+
const dirname = str.split("/").slice(0, -1).join("/");
|
|
231
|
+
const exist = await exists(dirname);
|
|
232
|
+
if (exist) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
await execCommand(`mkdir -p ${dirname}`);
|
|
236
|
+
};
|
|
229
237
|
var checkStrInFile = async (filePath, str) => {
|
|
230
238
|
const file = Bun.file(filePath);
|
|
231
239
|
if (!await file.exists()) {
|
|
@@ -238,9 +246,13 @@ var checkStrInFile = async (filePath, str) => {
|
|
|
238
246
|
return false;
|
|
239
247
|
};
|
|
240
248
|
var writeIfNew = async (filePath, str) => {
|
|
249
|
+
await createDir(filePath);
|
|
241
250
|
if (await checkStrInFile(filePath, str)) {
|
|
242
251
|
return;
|
|
243
252
|
}
|
|
253
|
+
if (!await Bun.file(filePath).exists()) {
|
|
254
|
+
await execCommand(`touch ${filePath}`);
|
|
255
|
+
}
|
|
244
256
|
await appendFile(filePath, finalizeWithNewline(str));
|
|
245
257
|
};
|
|
246
258
|
// src/ssh.ts
|
package/package.json
CHANGED