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.
Files changed (2) hide show
  1. package/dist/ramm.js +13 -1
  2. 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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ramm",
3
3
  "type": "module",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "scripts": {
6
6
  "build": "bun build ./src/ramm.ts --target bun --outdir ./dist && cp ./src/bun.sh ./dist/bun.sh && bun run types",
7
7
  "types": "tsc --project tsconfig.types.json"