@tstdl/base 0.92.17 → 0.92.18

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.
Files changed (2) hide show
  1. package/file/mime-type.js +13 -5
  2. package/package.json +1 -1
package/file/mime-type.js CHANGED
@@ -11,9 +11,17 @@ export function getMimeTypeExtensions(mimeType) {
11
11
  }
12
12
  async function spawnFileCommand(args, file) {
13
13
  const process = await spawnCommand('file', args, { stdinPipeOptions: { preventCancel: true } });
14
- const [stdout] = await Promise.all([
15
- process.readOutput(),
16
- isDefined(file) ? process.write(file) : undefined
17
- ]);
18
- return stdout.trim();
14
+ const { code } = await process.wait();
15
+ if (isDefined(file)) {
16
+ await process.write(file);
17
+ }
18
+ if (code != 0) {
19
+ const errorOutput = await process.readError();
20
+ throw new Error(errorOutput.trim());
21
+ }
22
+ const output = await process.readOutput();
23
+ if (output.includes('file or directory')) {
24
+ throw new Error(output.trim());
25
+ }
26
+ return output.trim();
19
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.17",
3
+ "version": "0.92.18",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"