ramm 0.0.15 → 0.0.16

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 CHANGED
@@ -239,7 +239,7 @@ EOF`);
239
239
  };
240
240
  // src/files.ts
241
241
  import { appendFile, exists } from "fs/promises";
242
- var {write } = globalThis.Bun;
242
+ var {file, write } = globalThis.Bun;
243
243
 
244
244
  // src/path.ts
245
245
  import { homedir } from "os";
@@ -270,11 +270,11 @@ var createDir = async (str) => {
270
270
  await execCommand(`mkdir -p ${dirname}`);
271
271
  };
272
272
  var checkStrInFile = async (filePath, str) => {
273
- const file = Bun.file(filePath);
274
- if (!await file.exists()) {
273
+ const file2 = Bun.file(filePath);
274
+ if (!await file2.exists()) {
275
275
  return false;
276
276
  }
277
- const fileText = await file.text();
277
+ const fileText = await file2.text();
278
278
  if (fileText.includes(str)) {
279
279
  return true;
280
280
  }
@@ -300,6 +300,15 @@ var writeFile = async (pathToFile, str) => {
300
300
  await createFileIfNeed(normalizedPath);
301
301
  await write(normalizedPath, str);
302
302
  };
303
+ var writeFileIfNotMatch = async (pathToFile, str) => {
304
+ const normalizedPath = normalizePath(pathToFile);
305
+ await createFileIfNeed(normalizedPath);
306
+ const fileText = await file(normalizedPath).text();
307
+ if (fileText === str) {
308
+ return;
309
+ }
310
+ await write(normalizedPath, str);
311
+ };
303
312
  // src/ssh.ts
304
313
  import { debug } from "console";
305
314
  var addKeyToHostConfig = async (pathToHost, address, pathToKey) => {
@@ -362,6 +371,7 @@ var createCron = async ({
362
371
  };
363
372
  export {
364
373
  writeIfNew,
374
+ writeFileIfNotMatch,
365
375
  writeFile,
366
376
  setupNftable,
367
377
  runPodmanContainerService,
@@ -1,2 +1,3 @@
1
1
  export declare const writeIfNew: (rawFilePath: string, str: string) => Promise<void>;
2
2
  export declare const writeFile: (pathToFile: string, str: string) => Promise<void>;
3
+ export declare const writeFileIfNotMatch: (pathToFile: string, str: string) => Promise<void>;
@@ -7,7 +7,7 @@ export { restartSystemdService } from "./systemd.ts";
7
7
  export { installSystemPackage } from "./packages.ts";
8
8
  export { debugBlock } from "./debug.ts";
9
9
  export { setupNftable } from "./nft.ts";
10
- export { writeIfNew, writeFile } from "./files.ts";
10
+ export { writeIfNew, writeFile, writeFileIfNotMatch } from "./files.ts";
11
11
  export { createAndAddSshKey, getServerFingerprintBySsh, addKeyToHostConfig, } from "./ssh.ts";
12
12
  export { normalizePath } from "./path.ts";
13
13
  export { createCron } from "./cron.ts";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ramm",
3
3
  "type": "module",
4
- "version": "0.0.15",
4
+ "version": "0.0.16",
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"