@augment-vir/node 31.67.0 → 31.67.1

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.
@@ -28,7 +28,10 @@ export async function readAllDirContents(dir, { recursive = false, excludeList,
28
28
  const contents = isFile
29
29
  ? (await readFile(filePath)).toString()
30
30
  : recursive
31
- ? await readAllDirContents(filePath, { recursive, excludeList })
31
+ ? await readAllDirContents(filePath, {
32
+ recursive,
33
+ excludeList,
34
+ })
32
35
  : undefined;
33
36
  if (check.isObject(contents) && !Object.keys(contents).length) {
34
37
  return undefined;
@@ -20,7 +20,9 @@ export async function downloadFile({ url, writePath }) {
20
20
  if (!response.body) {
21
21
  throw new Error(`Response body is missing from '${url}'.`);
22
22
  }
23
- await mkdir(dirname(writePath), { recursive: true });
23
+ await mkdir(dirname(writePath), {
24
+ recursive: true,
25
+ });
24
26
  const fileStream = createWriteStream(writePath);
25
27
  await finished(Readable.fromWeb(response.body).pipe(fileStream));
26
28
  }
@@ -34,7 +34,9 @@ export async function readJsonFile(path) {
34
34
  * - {@link appendJsonFile}
35
35
  */
36
36
  export async function writeJsonFile(path, data, options = {}) {
37
- await mkdir(dirname(path), { recursive: true });
37
+ await mkdir(dirname(path), {
38
+ recursive: true,
39
+ });
38
40
  const trailingNewLine = options.includeTrailingNewLine ? '\n' : '';
39
41
  await writeFileAndDir(path, JSON.stringify(data, null, 4) + trailingNewLine);
40
42
  }
@@ -19,7 +19,12 @@ export async function walkFiles({ handleFileContents, shouldRead, startDirPath,
19
19
  await awaitedForEach(children, async (file) => {
20
20
  const childPath = join(startDirPath, file.name);
21
21
  const isDir = file.isDirectory();
22
- const willRead = shouldRead ? await shouldRead({ path: childPath, isDir }) : true;
22
+ const willRead = shouldRead
23
+ ? await shouldRead({
24
+ path: childPath,
25
+ isDir,
26
+ })
27
+ : true;
23
28
  if (!willRead) {
24
29
  return;
25
30
  }
@@ -9,6 +9,8 @@ import { dirname } from 'node:path';
9
9
  * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
10
10
  */
11
11
  export async function writeFileAndDir(path, contents) {
12
- await mkdir(dirname(path), { recursive: true });
12
+ await mkdir(dirname(path), {
13
+ recursive: true,
14
+ });
13
15
  await writeFile(path, contents);
14
16
  }
@@ -41,7 +41,9 @@ export async function getWorkspacePackageJsonFilePaths(rootDirPath) {
41
41
  ? packageJson.workspaces
42
42
  : packageJson.workspaces?.packages || [];
43
43
  const matchedPaths = joinFilesToDir(rootDirPath, (await Promise.all(patterns.map(async (pattern) => {
44
- return await fromAsyncIterable(glob(pattern, { cwd: rootDirPath }));
44
+ return await fromAsyncIterable(glob(pattern, {
45
+ cwd: rootDirPath,
46
+ }));
45
47
  }))).flat());
46
48
  const workspacePackageJsonPaths = filterMap(matchedPaths, (matchedPath) => join(matchedPath, 'package.json'), (packageJsonPath) => existsSync(packageJsonPath));
47
49
  return workspacePackageJsonPaths.sort();
@@ -2,7 +2,9 @@ import { log } from '@augment-vir/common';
2
2
  import { convertDuration } from '@date-vir/duration';
3
3
  import { createInterface } from 'node:readline';
4
4
  const defaultAskQuestionOptions = {
5
- timeout: { seconds: 60 },
5
+ timeout: {
6
+ seconds: 60,
7
+ },
6
8
  hideUserInput: false,
7
9
  };
8
10
  /**
@@ -37,7 +39,9 @@ export async function askQuestion(questionToAsk, { hideUserInput = defaultAskQue
37
39
  process.kill(process.pid, 'SIGINT');
38
40
  });
39
41
  return new Promise((resolve, reject) => {
40
- const timeoutMs = convertDuration(timeout, { milliseconds: true }).milliseconds;
42
+ const timeoutMs = convertDuration(timeout, {
43
+ milliseconds: true,
44
+ }).milliseconds;
41
45
  const timeoutId = timeoutMs
42
46
  ? setTimeout(() => {
43
47
  cliInterface.close();
@@ -66,7 +66,12 @@ export class ShellTarget extends ListenTarget {
66
66
  */
67
67
  export function streamShellCommand(command, cwd, shell = 'bash', env = process.env, hookUpToConsole = false) {
68
68
  const stdio = hookUpToConsole ? [process.stdin] : undefined;
69
- const childProcess = spawn(command, { shell, cwd, env, stdio });
69
+ const childProcess = spawn(command, {
70
+ shell,
71
+ cwd,
72
+ env,
73
+ stdio,
74
+ });
70
75
  const shellTarget = new ShellTarget(childProcess);
71
76
  /** Type guards. */
72
77
  /* node:coverage ignore next 5 */
@@ -77,15 +82,21 @@ export function streamShellCommand(command, cwd, shell = 'bash', env = process.e
77
82
  throw new Error(`stderr emitter was not created by exec for some reason.`);
78
83
  }
79
84
  childProcess.stdout.on('data', (chunk) => {
80
- shellTarget.dispatch(new ShellStdoutEvent({ detail: chunk }));
85
+ shellTarget.dispatch(new ShellStdoutEvent({
86
+ detail: chunk,
87
+ }));
81
88
  });
82
89
  childProcess.stderr.on('data', (chunk) => {
83
- shellTarget.dispatch(new ShellStderrEvent({ detail: chunk }));
90
+ shellTarget.dispatch(new ShellStderrEvent({
91
+ detail: chunk,
92
+ }));
84
93
  });
85
94
  /** Idk how to trigger the 'error' event. */
86
- /* node:coverage ignore next 3 */
95
+ /* node:coverage ignore next 7 */
87
96
  childProcess.on('error', (error) => {
88
- shellTarget.dispatch(new ShellErrorEvent({ detail: error }));
97
+ shellTarget.dispatch(new ShellErrorEvent({
98
+ detail: error,
99
+ }));
89
100
  });
90
101
  /**
91
102
  * Based on the Node.js documentation, we should listen to "close" instead of "exit" because the
@@ -109,7 +120,9 @@ export function streamShellCommand(command, cwd, shell = 'bash', env = process.e
109
120
  execException.cmd = command;
110
121
  execException.killed = childProcess.killed;
111
122
  execException.cwd = cwd;
112
- shellTarget.dispatch(new ShellErrorEvent({ detail: execException }));
123
+ shellTarget.dispatch(new ShellErrorEvent({
124
+ detail: execException,
125
+ }));
113
126
  }
114
127
  shellTarget.dispatch(new ShellDoneEvent({
115
128
  detail: {
@@ -59,7 +59,9 @@ function createBinFileContents({ scriptPath }) {
59
59
  }
60
60
  async function fixTsBin(packageToFix) {
61
61
  const binFilePath = join(process.cwd(), 'node_modules', '.bin', packageToFix.binName);
62
- await rm(binFilePath, { force: true });
62
+ await rm(binFilePath, {
63
+ force: true,
64
+ });
63
65
  await writeFile(binFilePath, createBinFileContents(packageToFix));
64
66
  await runShellCommand(`chmod +x ${interpolationSafeWindowsPath(binFilePath)}`);
65
67
  await fixPackageJson(packageToFix);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/node",
3
- "version": "31.67.0",
3
+ "version": "31.67.1",
4
4
  "description": "A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.",
5
5
  "keywords": [
6
6
  "augment",
@@ -38,9 +38,9 @@
38
38
  "test:update": "npm test"
39
39
  },
40
40
  "dependencies": {
41
- "@augment-vir/assert": "^31.67.0",
42
- "@augment-vir/common": "^31.67.0",
43
- "@date-vir/duration": "^8.1.1",
41
+ "@augment-vir/assert": "^31.67.1",
42
+ "@augment-vir/common": "^31.67.1",
43
+ "@date-vir/duration": "^8.2.0",
44
44
  "ansi-styles": "^6.2.3",
45
45
  "sanitize-filename": "^1.6.3",
46
46
  "terminate": "^2.8.0",
@@ -49,12 +49,12 @@
49
49
  "typed-event-target": "^4.1.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@augment-vir/test": "^31.67.0",
53
- "@types/node": "^25.3.0",
52
+ "@augment-vir/test": "^31.67.1",
53
+ "@types/node": "^25.3.3",
54
54
  "@web/dev-server-esbuild": "^1.0.5",
55
55
  "@web/test-runner": "^0.20.2",
56
56
  "@web/test-runner-playwright": "^0.11.1",
57
- "c8": "^10.1.3",
57
+ "c8": "^11.0.0",
58
58
  "istanbul-smart-text-reporter": "^1.1.5",
59
59
  "typescript": "^5.9.3"
60
60
  },
@@ -54,7 +54,10 @@ export async function readAllDirContents(
54
54
  const contents = isFile
55
55
  ? (await readFile(filePath)).toString()
56
56
  : recursive
57
- ? await readAllDirContents(filePath, {recursive, excludeList})
57
+ ? await readAllDirContents(filePath, {
58
+ recursive,
59
+ excludeList,
60
+ })
58
61
  : undefined;
59
62
 
60
63
  if (check.isObject(contents) && !Object.keys(contents).length) {
@@ -25,7 +25,9 @@ export async function downloadFile({url, writePath}: {url: string; writePath: st
25
25
  throw new Error(`Response body is missing from '${url}'.`);
26
26
  }
27
27
 
28
- await mkdir(dirname(writePath), {recursive: true});
28
+ await mkdir(dirname(writePath), {
29
+ recursive: true,
30
+ });
29
31
  const fileStream = createWriteStream(writePath);
30
32
  await finished(Readable.fromWeb(response.body as ReadableStream).pipe(fileStream));
31
33
  }
@@ -57,7 +57,9 @@ export async function writeJsonFile(
57
57
  data: JsonCompatibleValue,
58
58
  options: WriteJsonOptions = {},
59
59
  ): Promise<void> {
60
- await mkdir(dirname(path), {recursive: true});
60
+ await mkdir(dirname(path), {
61
+ recursive: true,
62
+ });
61
63
 
62
64
  const trailingNewLine = options.includeTrailingNewLine ? '\n' : '';
63
65
 
@@ -66,7 +66,12 @@ export async function walkFiles({
66
66
  const childPath = join(startDirPath, file.name);
67
67
  const isDir = file.isDirectory();
68
68
 
69
- const willRead = shouldRead ? await shouldRead({path: childPath, isDir}) : true;
69
+ const willRead = shouldRead
70
+ ? await shouldRead({
71
+ path: childPath,
72
+ isDir,
73
+ })
74
+ : true;
70
75
 
71
76
  if (!willRead) {
72
77
  return;
@@ -13,6 +13,8 @@ export async function writeFileAndDir(
13
13
  path: string,
14
14
  contents: string | NodeJS.ArrayBufferView,
15
15
  ): Promise<void> {
16
- await mkdir(dirname(path), {recursive: true});
16
+ await mkdir(dirname(path), {
17
+ recursive: true,
18
+ });
17
19
  await writeFile(path, contents);
18
20
  }
@@ -59,7 +59,11 @@ export async function getWorkspacePackageJsonFilePaths(rootDirPath: string): Pro
59
59
  (
60
60
  await Promise.all(
61
61
  patterns.map(async (pattern) => {
62
- return await fromAsyncIterable(glob(pattern, {cwd: rootDirPath}));
62
+ return await fromAsyncIterable(
63
+ glob(pattern, {
64
+ cwd: rootDirPath,
65
+ }),
66
+ );
63
67
  }),
64
68
  )
65
69
  ).flat(),
@@ -18,7 +18,9 @@ export type AskQuestionOptions = {
18
18
  };
19
19
 
20
20
  const defaultAskQuestionOptions: AskQuestionOptions = {
21
- timeout: {seconds: 60},
21
+ timeout: {
22
+ seconds: 60,
23
+ },
22
24
  hideUserInput: false,
23
25
  };
24
26
 
@@ -67,7 +69,9 @@ export async function askQuestion(
67
69
  });
68
70
 
69
71
  return new Promise((resolve, reject) => {
70
- const timeoutMs = convertDuration(timeout, {milliseconds: true}).milliseconds;
72
+ const timeoutMs = convertDuration(timeout, {
73
+ milliseconds: true,
74
+ }).milliseconds;
71
75
 
72
76
  const timeoutId = timeoutMs
73
77
  ? setTimeout(() => {
@@ -95,7 +95,12 @@ export function streamShellCommand(
95
95
  ): ShellTarget {
96
96
  const stdio = hookUpToConsole ? [process.stdin] : undefined;
97
97
 
98
- const childProcess = spawn(command, {shell, cwd, env, stdio});
98
+ const childProcess = spawn(command, {
99
+ shell,
100
+ cwd,
101
+ env,
102
+ stdio,
103
+ });
99
104
  const shellTarget = new ShellTarget(childProcess);
100
105
 
101
106
  /** Type guards. */
@@ -107,16 +112,28 @@ export function streamShellCommand(
107
112
  }
108
113
 
109
114
  childProcess.stdout.on('data', (chunk) => {
110
- shellTarget.dispatch(new ShellStdoutEvent({detail: chunk}));
115
+ shellTarget.dispatch(
116
+ new ShellStdoutEvent({
117
+ detail: chunk,
118
+ }),
119
+ );
111
120
  });
112
121
  childProcess.stderr.on('data', (chunk) => {
113
- shellTarget.dispatch(new ShellStderrEvent({detail: chunk}));
122
+ shellTarget.dispatch(
123
+ new ShellStderrEvent({
124
+ detail: chunk,
125
+ }),
126
+ );
114
127
  });
115
128
 
116
129
  /** Idk how to trigger the 'error' event. */
117
- /* node:coverage ignore next 3 */
130
+ /* node:coverage ignore next 7 */
118
131
  childProcess.on('error', (error) => {
119
- shellTarget.dispatch(new ShellErrorEvent({detail: error}));
132
+ shellTarget.dispatch(
133
+ new ShellErrorEvent({
134
+ detail: error,
135
+ }),
136
+ );
120
137
  });
121
138
  /**
122
139
  * Based on the Node.js documentation, we should listen to "close" instead of "exit" because the
@@ -143,7 +160,11 @@ export function streamShellCommand(
143
160
  execException.cmd = command;
144
161
  execException.killed = childProcess.killed;
145
162
  execException.cwd = cwd;
146
- shellTarget.dispatch(new ShellErrorEvent({detail: execException}));
163
+ shellTarget.dispatch(
164
+ new ShellErrorEvent({
165
+ detail: execException,
166
+ }),
167
+ );
147
168
  }
148
169
  shellTarget.dispatch(
149
170
  new ShellDoneEvent({
@@ -71,7 +71,9 @@ function createBinFileContents({scriptPath}: Readonly<Pick<PackageToFix, 'script
71
71
 
72
72
  async function fixTsBin(packageToFix: Readonly<PackageToFix>) {
73
73
  const binFilePath = join(process.cwd(), 'node_modules', '.bin', packageToFix.binName);
74
- await rm(binFilePath, {force: true});
74
+ await rm(binFilePath, {
75
+ force: true,
76
+ });
75
77
  await writeFile(binFilePath, createBinFileContents(packageToFix));
76
78
  await runShellCommand(`chmod +x ${interpolationSafeWindowsPath(binFilePath)}`);
77
79
  await fixPackageJson(packageToFix);