terminal-png 0.1.2 → 0.1.3

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 +9 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15,16 +15,20 @@ export async function renderTerminalPng(ansiText, options = {}) {
15
15
  const png = renderPng(svg);
16
16
  if (options.output) {
17
17
  const temporaryPath = `${options.output}.${randomUUID()}.tmp`;
18
+ let temporaryCreated = false;
18
19
  try {
19
20
  await writeFile(temporaryPath, png, { flag: "wx" });
21
+ temporaryCreated = true;
20
22
  await rename(temporaryPath, options.output);
21
23
  }
22
24
  catch (error) {
23
- try {
24
- await rm(temporaryPath, { force: true });
25
- }
26
- catch (cleanupError) {
27
- void cleanupError;
25
+ if (temporaryCreated) {
26
+ try {
27
+ await rm(temporaryPath, { force: true });
28
+ }
29
+ catch (cleanupError) {
30
+ void cleanupError;
31
+ }
28
32
  }
29
33
  throw error;
30
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-png",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Render PNG images from ANSI terminal output.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",