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 +14 -4
- package/dist/types/files.d.ts +1 -0
- package/dist/types/ramm.d.ts +1 -1
- package/package.json +1 -1
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
|
|
274
|
-
if (!await
|
|
273
|
+
const file2 = Bun.file(filePath);
|
|
274
|
+
if (!await file2.exists()) {
|
|
275
275
|
return false;
|
|
276
276
|
}
|
|
277
|
-
const fileText = await
|
|
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,
|
package/dist/types/files.d.ts
CHANGED
package/dist/types/ramm.d.ts
CHANGED
|
@@ -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