@williamthorsen/nmr-core 0.5.0 → 0.6.0
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/README.md +3 -3
- package/dist/esm/.cache +1 -1
- package/dist/esm/findPackageRoot.js +12 -15
- package/dist/esm/index.d.ts +7 -7
- package/dist/esm/index.js +6 -30
- package/dist/esm/parseArgs.js +77 -80
- package/dist/esm/readPackageVersion.js +10 -13
- package/dist/esm/terminal.d.ts +1 -1
- package/dist/esm/terminal.js +51 -59
- package/dist/esm/writeFileWithCheck.js +39 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,13 +5,13 @@ Shared utilities for node-monorepo-tools packages.
|
|
|
5
5
|
This package serves as the shared library foundation for the monorepo. For the nmr CLI tool, see [`@williamthorsen/nmr`](../nmr).
|
|
6
6
|
|
|
7
7
|
<!-- section:release-notes -->
|
|
8
|
-
## Release notes — v0.
|
|
8
|
+
## Release notes — v0.6.0 (2026-07-01)
|
|
9
9
|
|
|
10
10
|
### 🎉 Features
|
|
11
11
|
|
|
12
|
-
-
|
|
12
|
+
- 🚨 **Breaking:** Rebuild nmr-compile on a unified tsc emit (#455)
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
`nmr` now compiles a package's JavaScript and type declarations in one step, rewriting every import form — static, re-export, dynamic `import()`, bare side-effect, and tsconfig `paths` aliases — to runnable `.js` in both outputs. It now requires TypeScript 5.7 or newer as a peer dependency.
|
|
15
15
|
<!-- /section:release-notes -->
|
|
16
16
|
|
|
17
17
|
## Installation
|
package/dist/esm/.cache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6527d41fa47a32d6ecdb2ccb3a4414d730a2cd4b9ca6522babe60a12bac7acf1
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { existsSync } from
|
|
2
|
-
import { dirname, resolve } from
|
|
3
|
-
import { fileURLToPath } from
|
|
4
|
-
function findPackageRoot(fromUrl) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
export function findPackageRoot(fromUrl) {
|
|
5
|
+
let dir = dirname(fileURLToPath(fromUrl));
|
|
6
|
+
while (!existsSync(resolve(dir, 'package.json'))) {
|
|
7
|
+
const parent = dirname(dir);
|
|
8
|
+
if (parent === dir) {
|
|
9
|
+
throw new Error('Could not find package root from ' + fromUrl);
|
|
10
|
+
}
|
|
11
|
+
dir = parent;
|
|
10
12
|
}
|
|
11
|
-
dir
|
|
12
|
-
}
|
|
13
|
-
return dir;
|
|
13
|
+
return dir;
|
|
14
14
|
}
|
|
15
|
-
export {
|
|
16
|
-
findPackageRoot
|
|
17
|
-
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const PACKAGE_NAME = "@williamthorsen/nmr-core";
|
|
2
|
-
export { findPackageRoot } from './findPackageRoot.
|
|
3
|
-
export type { FlagDefinition, FlagSchema, ParseArgsOptions, ParsedArgs, ParsedFlags, ParseErrorKind, } from './parseArgs.
|
|
4
|
-
export { parseArgs, parseArgsOrExit, ParseError } from './parseArgs.
|
|
5
|
-
export { readPackageVersion } from './readPackageVersion.
|
|
6
|
-
export { formatErrorLine, printError, printSkip, printStep, printSuccess, reportError, reportWriteResult, } from './terminal.
|
|
7
|
-
export type { WriteOutcome, WriteResult } from './writeFileWithCheck.
|
|
8
|
-
export { writeFileWithCheck } from './writeFileWithCheck.
|
|
2
|
+
export { findPackageRoot } from './findPackageRoot.js';
|
|
3
|
+
export type { FlagDefinition, FlagSchema, ParseArgsOptions, ParsedArgs, ParsedFlags, ParseErrorKind, } from './parseArgs.js';
|
|
4
|
+
export { parseArgs, parseArgsOrExit, ParseError } from './parseArgs.js';
|
|
5
|
+
export { readPackageVersion } from './readPackageVersion.js';
|
|
6
|
+
export { formatErrorLine, printError, printSkip, printStep, printSuccess, reportError, reportWriteResult, } from './terminal.js';
|
|
7
|
+
export type { WriteOutcome, WriteResult } from './writeFileWithCheck.js';
|
|
8
|
+
export { writeFileWithCheck } from './writeFileWithCheck.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
const PACKAGE_NAME =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
printError,
|
|
8
|
-
printSkip,
|
|
9
|
-
printStep,
|
|
10
|
-
printSuccess,
|
|
11
|
-
reportError,
|
|
12
|
-
reportWriteResult
|
|
13
|
-
} from "./terminal.js";
|
|
14
|
-
import { writeFileWithCheck } from "./writeFileWithCheck.js";
|
|
15
|
-
export {
|
|
16
|
-
PACKAGE_NAME,
|
|
17
|
-
ParseError,
|
|
18
|
-
findPackageRoot,
|
|
19
|
-
formatErrorLine,
|
|
20
|
-
parseArgs,
|
|
21
|
-
parseArgsOrExit,
|
|
22
|
-
printError,
|
|
23
|
-
printSkip,
|
|
24
|
-
printStep,
|
|
25
|
-
printSuccess,
|
|
26
|
-
readPackageVersion,
|
|
27
|
-
reportError,
|
|
28
|
-
reportWriteResult,
|
|
29
|
-
writeFileWithCheck
|
|
30
|
-
};
|
|
1
|
+
export const PACKAGE_NAME = '@williamthorsen/nmr-core';
|
|
2
|
+
export { findPackageRoot } from "./findPackageRoot.js";
|
|
3
|
+
export { parseArgs, parseArgsOrExit, ParseError } from "./parseArgs.js";
|
|
4
|
+
export { readPackageVersion } from "./readPackageVersion.js";
|
|
5
|
+
export { formatErrorLine, printError, printSkip, printStep, printSuccess, reportError, reportWriteResult, } from "./terminal.js";
|
|
6
|
+
export { writeFileWithCheck } from "./writeFileWithCheck.js";
|
package/dist/esm/parseArgs.js
CHANGED
|
@@ -1,89 +1,86 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { parseArgs as nodeParseArgs } from
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { parseArgs as nodeParseArgs } from 'node:util';
|
|
3
3
|
import { reportError } from "./terminal.js";
|
|
4
|
-
class ParseError extends Error {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function parseArgs(argv, schema, options = {}) {
|
|
15
|
-
const nodeOptions = {};
|
|
16
|
-
const byName = /* @__PURE__ */ new Map();
|
|
17
|
-
const flags = {};
|
|
18
|
-
for (const [key, def] of Object.entries(schema)) {
|
|
19
|
-
const name = def.long.replace(/^--/, "");
|
|
20
|
-
nodeOptions[name] = def.short === void 0 ? { type: def.type } : { type: def.type, short: def.short.replace(/^-/, "") };
|
|
21
|
-
byName.set(name, { key, def });
|
|
22
|
-
flags[key] = def.type === "boolean" ? false : void 0;
|
|
23
|
-
}
|
|
24
|
-
const { tokens } = nodeParseArgs({
|
|
25
|
-
args: argv,
|
|
26
|
-
options: nodeOptions,
|
|
27
|
-
strict: false,
|
|
28
|
-
allowPositionals: true,
|
|
29
|
-
tokens: true
|
|
30
|
-
});
|
|
31
|
-
const positionals = [];
|
|
32
|
-
for (const token of tokens) {
|
|
33
|
-
if (token.kind === "positional") {
|
|
34
|
-
if (options.allowPositionals !== true) {
|
|
35
|
-
throw new ParseError("unexpected-positional", token.value);
|
|
36
|
-
}
|
|
37
|
-
positionals.push(token.value);
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (token.kind !== "option") {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
const entry = byName.get(token.name);
|
|
44
|
-
if (entry === void 0) {
|
|
45
|
-
throw new ParseError("unknown-flag", token.rawName);
|
|
4
|
+
export class ParseError extends Error {
|
|
5
|
+
kind;
|
|
6
|
+
flag;
|
|
7
|
+
constructor(kind, flag) {
|
|
8
|
+
super(formatParseErrorMessage(kind, flag));
|
|
9
|
+
this.name = 'ParseError';
|
|
10
|
+
this.kind = kind;
|
|
11
|
+
this.flag = flag;
|
|
46
12
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
13
|
+
}
|
|
14
|
+
export function parseArgs(argv, schema, options = {}) {
|
|
15
|
+
const nodeOptions = {};
|
|
16
|
+
const byName = new Map();
|
|
17
|
+
const flags = {};
|
|
18
|
+
for (const [key, def] of Object.entries(schema)) {
|
|
19
|
+
const name = def.long.replace(/^--/, '');
|
|
20
|
+
nodeOptions[name] =
|
|
21
|
+
def.short === undefined ? { type: def.type } : { type: def.type, short: def.short.replace(/^-/, '') };
|
|
22
|
+
byName.set(name, { key, def });
|
|
23
|
+
flags[key] = def.type === 'boolean' ? false : undefined;
|
|
53
24
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
25
|
+
const { tokens } = nodeParseArgs({
|
|
26
|
+
args: argv,
|
|
27
|
+
options: nodeOptions,
|
|
28
|
+
strict: false,
|
|
29
|
+
allowPositionals: true,
|
|
30
|
+
tokens: true,
|
|
31
|
+
});
|
|
32
|
+
const positionals = [];
|
|
33
|
+
for (const token of tokens) {
|
|
34
|
+
if (token.kind === 'positional') {
|
|
35
|
+
if (options.allowPositionals !== true) {
|
|
36
|
+
throw new ParseError('unexpected-positional', token.value);
|
|
37
|
+
}
|
|
38
|
+
positionals.push(token.value);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (token.kind !== 'option') {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const entry = byName.get(token.name);
|
|
45
|
+
if (entry === undefined) {
|
|
46
|
+
throw new ParseError('unknown-flag', token.rawName);
|
|
47
|
+
}
|
|
48
|
+
if (entry.def.type === 'boolean') {
|
|
49
|
+
if (token.value !== undefined) {
|
|
50
|
+
throw new ParseError('unexpected-value', token.rawName);
|
|
51
|
+
}
|
|
52
|
+
flags[entry.key] = true;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const value = token.value;
|
|
56
|
+
if (value === undefined || value === '' || (!token.inlineValue && value.startsWith('-') && value !== '-')) {
|
|
57
|
+
throw new ParseError('missing-value', token.rawName);
|
|
58
|
+
}
|
|
59
|
+
flags[entry.key] = value;
|
|
57
60
|
}
|
|
58
|
-
flags
|
|
59
|
-
}
|
|
60
|
-
return { flags, positionals };
|
|
61
|
+
return { flags, positionals };
|
|
61
62
|
}
|
|
62
|
-
function parseArgsOrExit(argv, schema, options = {}) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
export function parseArgsOrExit(argv, schema, options = {}) {
|
|
64
|
+
try {
|
|
65
|
+
return parseArgs(argv, schema, options);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof ParseError) {
|
|
69
|
+
reportError(error.message);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
69
73
|
}
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
74
|
}
|
|
73
75
|
function formatParseErrorMessage(kind, flag) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
switch (kind) {
|
|
77
|
+
case 'unknown-flag':
|
|
78
|
+
return `Unknown option: ${flag}`;
|
|
79
|
+
case 'missing-value':
|
|
80
|
+
return `Missing value for option: ${flag}`;
|
|
81
|
+
case 'unexpected-value':
|
|
82
|
+
return `Option does not accept a value: ${flag}`;
|
|
83
|
+
case 'unexpected-positional':
|
|
84
|
+
return `Unexpected positional argument: ${flag}`;
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
|
-
export {
|
|
86
|
-
ParseError,
|
|
87
|
-
parseArgs,
|
|
88
|
-
parseArgsOrExit
|
|
89
|
-
};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { readFileSync } from
|
|
2
|
-
import { resolve } from
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
3
|
import { findPackageRoot } from "./findPackageRoot.js";
|
|
4
|
-
function readPackageVersion(fromUrl) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export function readPackageVersion(fromUrl) {
|
|
5
|
+
const root = findPackageRoot(fromUrl);
|
|
6
|
+
const packageJsonPath = resolve(root, 'package.json');
|
|
7
|
+
const raw = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
8
|
+
if (typeof raw !== 'object' || raw === null || !('version' in raw) || typeof raw.version !== 'string') {
|
|
9
|
+
throw new Error(`No string "version" field in ${packageJsonPath}`);
|
|
10
|
+
}
|
|
11
|
+
return raw.version;
|
|
12
12
|
}
|
|
13
|
-
export {
|
|
14
|
-
readPackageVersion
|
|
15
|
-
};
|
package/dist/esm/terminal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Writable } from 'node:stream';
|
|
2
|
-
import type { WriteResult } from './writeFileWithCheck.
|
|
2
|
+
import type { WriteResult } from './writeFileWithCheck.js';
|
|
3
3
|
export declare function formatErrorLine(message: string): string;
|
|
4
4
|
export declare function printError(message: string): void;
|
|
5
5
|
export declare function printSkip(message: string): void;
|
package/dist/esm/terminal.js
CHANGED
|
@@ -1,66 +1,58 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
function formatErrorLine(message) {
|
|
3
|
-
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
export function formatErrorLine(message) {
|
|
3
|
+
return `Error: ${message}`;
|
|
4
4
|
}
|
|
5
|
-
function printError(message) {
|
|
6
|
-
|
|
7
|
-
`);
|
|
5
|
+
export function printError(message) {
|
|
6
|
+
process.stderr.write(` ❌ ${message}\n`);
|
|
8
7
|
}
|
|
9
|
-
function printSkip(message) {
|
|
10
|
-
|
|
8
|
+
export function printSkip(message) {
|
|
9
|
+
console.info(` ⚠️ ${message}`);
|
|
11
10
|
}
|
|
12
|
-
function printStep(message) {
|
|
13
|
-
|
|
14
|
-
> ${message}`);
|
|
11
|
+
export function printStep(message) {
|
|
12
|
+
console.info(`\n> ${message}`);
|
|
15
13
|
}
|
|
16
|
-
function printSuccess(message) {
|
|
17
|
-
|
|
14
|
+
export function printSuccess(message) {
|
|
15
|
+
console.info(` ✅ ${message}`);
|
|
18
16
|
}
|
|
19
|
-
function reportError(message, stream = process.stderr) {
|
|
20
|
-
|
|
21
|
-
`);
|
|
17
|
+
export function reportError(message, stream = process.stderr) {
|
|
18
|
+
stream.write(`${formatErrorLine(message)}\n`);
|
|
22
19
|
}
|
|
23
|
-
function reportWriteResult(result, dryRun) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
20
|
+
export function reportWriteResult(result, dryRun) {
|
|
21
|
+
switch (result.outcome) {
|
|
22
|
+
case 'created':
|
|
23
|
+
if (dryRun) {
|
|
24
|
+
printSuccess(`[dry-run] Would create ${result.filePath}`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
printSuccess(`Created ${result.filePath}`);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case 'overwritten':
|
|
31
|
+
if (dryRun) {
|
|
32
|
+
printSuccess(`[dry-run] Would overwrite ${result.filePath}`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
printSuccess(`Overwrote ${result.filePath}`);
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case 'up-to-date':
|
|
39
|
+
printSuccess(`${result.filePath} (up to date)`);
|
|
40
|
+
break;
|
|
41
|
+
case 'skipped':
|
|
42
|
+
if (result.error) {
|
|
43
|
+
printSkip(`${result.filePath} (could not read for comparison: ${result.error})`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
printSkip(`${result.filePath} (already exists)`);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case 'failed':
|
|
50
|
+
if (result.error) {
|
|
51
|
+
printError(`Failed to write ${result.filePath}: ${result.error}`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
printError(`Failed to write ${result.filePath}`);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
57
58
|
}
|
|
58
|
-
export {
|
|
59
|
-
formatErrorLine,
|
|
60
|
-
printError,
|
|
61
|
-
printSkip,
|
|
62
|
-
printStep,
|
|
63
|
-
printSuccess,
|
|
64
|
-
reportError,
|
|
65
|
-
reportWriteResult
|
|
66
|
-
};
|
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from
|
|
2
|
-
import { dirname } from
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
3
|
function normalizeTrailingWhitespace(content) {
|
|
4
|
-
|
|
4
|
+
return content
|
|
5
|
+
.split('\n')
|
|
6
|
+
.map((line) => line.trimEnd())
|
|
7
|
+
.join('\n')
|
|
8
|
+
.trimEnd();
|
|
5
9
|
}
|
|
6
|
-
function writeFileWithCheck(filePath, content, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
export function writeFileWithCheck(filePath, content, options) {
|
|
11
|
+
const { dryRun, overwrite } = options;
|
|
12
|
+
const fileExists = existsSync(filePath);
|
|
13
|
+
if (fileExists && !overwrite) {
|
|
14
|
+
try {
|
|
15
|
+
const existing = readFileSync(filePath, 'utf8');
|
|
16
|
+
if (normalizeTrailingWhitespace(existing) === normalizeTrailingWhitespace(content)) {
|
|
17
|
+
return { filePath, outcome: 'up-to-date' };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
22
|
+
return { filePath, outcome: 'skipped', error: message };
|
|
23
|
+
}
|
|
24
|
+
return { filePath, outcome: 'skipped' };
|
|
25
|
+
}
|
|
26
|
+
const outcome = fileExists ? 'overwritten' : 'created';
|
|
27
|
+
if (dryRun) {
|
|
28
|
+
return { filePath, outcome };
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
return { filePath, outcome: 'failed', error: message };
|
|
36
|
+
}
|
|
10
37
|
try {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
17
|
-
return { filePath, outcome: "skipped", error: message };
|
|
38
|
+
writeFileSync(filePath, content, 'utf8');
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
42
|
+
return { filePath, outcome: 'failed', error: message };
|
|
18
43
|
}
|
|
19
|
-
return { filePath, outcome: "skipped" };
|
|
20
|
-
}
|
|
21
|
-
const outcome = fileExists ? "overwritten" : "created";
|
|
22
|
-
if (dryRun) {
|
|
23
44
|
return { filePath, outcome };
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
mkdirSync(dirname(filePath), { recursive: true });
|
|
27
|
-
} catch (error) {
|
|
28
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
29
|
-
return { filePath, outcome: "failed", error: message };
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
writeFileSync(filePath, content, "utf8");
|
|
33
|
-
} catch (error) {
|
|
34
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
-
return { filePath, outcome: "failed", error: message };
|
|
36
|
-
}
|
|
37
|
-
return { filePath, outcome };
|
|
38
45
|
}
|
|
39
|
-
export {
|
|
40
|
-
writeFileWithCheck
|
|
41
|
-
};
|