@koine/node 2.0.0-beta.36 → 2.0.0-beta.38

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/fsWrite.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function fsWrite(filepath: string, content: string): Promise<void>;
1
+ export declare function fsWrite(filepath: string, content: string, eol?: boolean): Promise<void>;
package/fsWrite.js CHANGED
@@ -1,17 +1,25 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
- import { mkdir, writeFile } from "node:fs/promises";
2
+ import { appendFile, mkdir, writeFile } from "node:fs/promises";
3
+ import { EOL } from "node:os";
3
4
  import { dirname } from "node:path";
4
- export function fsWrite(filepath, content) {
5
+ export function fsWrite(filepath, content, eol) {
6
+ if (eol === void 0) { eol = true; }
5
7
  return __awaiter(this, void 0, void 0, function () {
6
8
  return __generator(this, function (_a) {
7
9
  switch (_a.label) {
8
10
  case 0: return [4, mkdir(dirname(filepath), { recursive: true })];
9
11
  case 1:
10
12
  _a.sent();
13
+ content = content.replace(/^\s*/m, "");
11
14
  return [4, writeFile(filepath, content)];
12
15
  case 2:
13
16
  _a.sent();
14
- return [2];
17
+ if (!eol) return [3, 4];
18
+ return [4, appendFile(filepath, EOL, "utf8")];
19
+ case 3:
20
+ _a.sent();
21
+ _a.label = 4;
22
+ case 4: return [2];
15
23
  }
16
24
  });
17
25
  });
@@ -0,0 +1 @@
1
+ export * from "./jestCreateExpectedThrownError.js";
package/jest/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./jestCreateExpectedThrownError.js";
@@ -0,0 +1 @@
1
+ export declare const jestCreateExpectedThrownError: (pkgName: string, fnName: string) => (expectFn: () => ReturnType<jest.Expect>) => void;
@@ -0,0 +1,11 @@
1
+ import { log } from "console";
2
+ export var jestCreateExpectedThrownError = function (pkgName, fnName) {
3
+ return function (expectFn) {
4
+ try {
5
+ expectFn().toThrow(new RegExp("\\[".concat(pkgName, "\\]::").concat(fnName, ", .*"), "g"));
6
+ }
7
+ catch (e) {
8
+ log("\x1b[32m", " ✓", "\x1b[0m", "throw", "\x1b[2m", e.message.replace("[".concat(pkgName, "]::").concat(fnName, ", "), ""));
9
+ }
10
+ };
11
+ };
package/package.json CHANGED
@@ -9,8 +9,14 @@
9
9
  },
10
10
  "./fsWrite": {
11
11
  "import": "./fsWrite.js"
12
+ },
13
+ "./jest": {
14
+ "import": "./jest/index.js"
15
+ },
16
+ "./jest/jestCreateExpectedThrownError": {
17
+ "import": "./jest/jestCreateExpectedThrownError.js"
12
18
  }
13
19
  },
14
20
  "dependencies": {},
15
- "version": "2.0.0-beta.36"
21
+ "version": "2.0.0-beta.38"
16
22
  }