terminal-png 0.1.3 → 0.1.4

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/dist/index.js +4 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ export async function renderTerminalPng(ansiText, options = {}) {
22
22
  await rename(temporaryPath, options.output);
23
23
  }
24
24
  catch (error) {
25
- if (temporaryCreated) {
25
+ if (temporaryCreated || !isAlreadyExistsError(error)) {
26
26
  try {
27
27
  await rm(temporaryPath, { force: true });
28
28
  }
@@ -35,6 +35,9 @@ export async function renderTerminalPng(ansiText, options = {}) {
35
35
  }
36
36
  return png;
37
37
  }
38
+ function isAlreadyExistsError(error) {
39
+ return error instanceof Error && "code" in error && error.code === "EEXIST";
40
+ }
38
41
  export * from "./ansi-parser.js";
39
42
  export * from "./font.js";
40
43
  export * from "./png-renderer.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-png",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Render PNG images from ANSI terminal output.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",