@tstdl/base 0.92.40 → 0.92.42

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/file/mime-type.js CHANGED
@@ -10,11 +10,14 @@ export function getMimeTypeExtensions(mimeType) {
10
10
  return mimeTypesMap.get(mimeType) ?? [];
11
11
  }
12
12
  async function spawnFileCommand(args, file) {
13
- const process = await spawnCommand('file', args, { stdinPipeOptions: { preventCancel: true } });
14
- const { code } = await process.wait();
13
+ const process = await spawnCommand('file', args);
15
14
  if (isDefined(file)) {
16
- await process.write(file);
15
+ try {
16
+ await process.write(file);
17
+ }
18
+ catch { /* ignore as file command closes stdin early */ }
17
19
  }
20
+ const { code } = await process.wait();
18
21
  if (code != 0) {
19
22
  const errorOutput = await process.readError();
20
23
  throw new Error(errorOutput.trim());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.40",
3
+ "version": "0.92.42",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -118,8 +118,8 @@
118
118
  "./utils/string": "./utils/string/index.js"
119
119
  },
120
120
  "dependencies": {
121
- "@google-cloud/storage": "^7.15.0",
122
- "@google-cloud/vertexai": "^1.9.2",
121
+ "@google-cloud/storage": "7.15",
122
+ "@google-cloud/vertexai": "1.9",
123
123
  "disposablestack": "1.1",
124
124
  "luxon": "^3.5",
125
125
  "reflect-metadata": "^0.2",
@@ -164,9 +164,9 @@
164
164
  "koa": "^2.15",
165
165
  "minio": "^8.0",
166
166
  "mjml": "^4.15",
167
- "mongodb": "^6.12",
167
+ "mongodb": "^6.13",
168
168
  "nodemailer": "^6.10",
169
- "pg": "8.13",
169
+ "pg": "^8.13",
170
170
  "playwright": "^1.50",
171
171
  "preact": "^10.25",
172
172
  "preact-render-to-string": "^6.5",
@@ -2,7 +2,7 @@ import type { ChildProcessWithoutNullStreams } from 'node:child_process';
2
2
  export type SpawnCommandResult = TransformStream<Uint8Array, Uint8Array> & {
3
3
  process: ChildProcessWithoutNullStreams;
4
4
  stderr: ReadableStream<Uint8Array>;
5
- write(chunk: ReadableStream<Uint8Array> | Uint8Array | string): Promise<void>;
5
+ write(chunk: ReadableStream<Uint8Array> | Uint8Array | string, options?: StreamPipeOptions): Promise<void>;
6
6
  readOutputBytes(): Promise<Uint8Array>;
7
7
  readOutput(): Promise<string>;
8
8
  readErrorBytes(): Promise<Uint8Array>;
@@ -12,6 +12,4 @@ export type SpawnCommandResult = TransformStream<Uint8Array, Uint8Array> & {
12
12
  signal: string | null;
13
13
  }>;
14
14
  };
15
- export declare function spawnCommand(command: string, args?: string[], options?: {
16
- stdinPipeOptions?: StreamPipeOptions;
17
- }): Promise<SpawnCommandResult>;
15
+ export declare function spawnCommand(command: string, args?: string[]): Promise<SpawnCommandResult>;
package/process/spawn.js CHANGED
@@ -3,7 +3,7 @@ import { decodeTextStream, encodeUtf8Stream } from '../utils/encoding.js';
3
3
  import { readBinaryStream, readTextStream } from '../utils/stream/stream-reader.js';
4
4
  import { toReadableStream } from '../utils/stream/to-readable-stream.js';
5
5
  import { isReadableStream, isString, isUint8Array } from '../utils/type-guards.js';
6
- export async function spawnCommand(command, args, options) {
6
+ export async function spawnCommand(command, args) {
7
7
  const { spawn } = await dynamicImport('node:child_process');
8
8
  const { Readable, Writable } = await dynamicImport('node:stream');
9
9
  const process = spawn(command, args, { stdio: 'pipe' });
@@ -14,15 +14,15 @@ export async function spawnCommand(command, args, options) {
14
14
  const readable = Readable.toWeb(process.stdout);
15
15
  const writable = Writable.toWeb(process.stdin);
16
16
  const stderr = Readable.toWeb(process.stderr);
17
- async function write(data) {
17
+ async function write(data, options) {
18
18
  if (isReadableStream(data)) {
19
- await data.pipeTo(writable, options?.stdinPipeOptions);
19
+ await data.pipeTo(writable, options);
20
20
  }
21
21
  else if (isUint8Array(data)) {
22
- await toReadableStream(data).pipeTo(writable, options?.stdinPipeOptions);
22
+ await toReadableStream(data).pipeTo(writable, options);
23
23
  }
24
24
  else if (isString(data)) {
25
- await toReadableStream(data).pipeThrough(encodeUtf8Stream()).pipeTo(writable, options?.stdinPipeOptions);
25
+ await toReadableStream(data).pipeThrough(encodeUtf8Stream()).pipeTo(writable, options);
26
26
  }
27
27
  }
28
28
  async function readOutputBytes() {
@@ -31,10 +31,10 @@ export async function spawnCommand(command, args, options) {
31
31
  async function readOutput() {
32
32
  return readTextStream(readable.pipeThrough(decodeTextStream()));
33
33
  }
34
- async function readErrBytes() {
34
+ async function readErrorBytes() {
35
35
  return readBinaryStream(stderr);
36
36
  }
37
- async function readErr() {
37
+ async function readError() {
38
38
  return readTextStream(stderr.pipeThrough(decodeTextStream()));
39
39
  }
40
40
  const signalPromise = new Promise((resolve) => process.on('close', (code, signal) => resolve({ code, signal })));
@@ -46,8 +46,8 @@ export async function spawnCommand(command, args, options) {
46
46
  write,
47
47
  readOutputBytes,
48
48
  readOutput,
49
- readErrorBytes: readErrBytes,
50
- readError: readErr,
49
+ readErrorBytes,
50
+ readError,
51
51
  async wait() {
52
52
  return signalPromise;
53
53
  }