ts-graphviz 1.3.3-dev.dc36620d2 → 1.3.4-dev.c1e4c50a9

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.
@@ -16,6 +16,7 @@ export async function toStream(dot, options) {
16
16
  const cp = new Deno.Command(command, {
17
17
  args: args,
18
18
  stdin: 'piped',
19
+ stdout: 'piped',
19
20
  }).spawn();
20
21
  const stdin = cp.stdin.getWriter();
21
22
  await stdin.write(new TextEncoder().encode(dot));
@@ -23,11 +24,22 @@ export async function toStream(dot, options) {
23
24
  return cp.stdout;
24
25
  }
25
26
 
27
+ function open(path) {
28
+ try {
29
+ return Deno.open(path, { write: true });
30
+ } catch (e) {
31
+ if (e instanceof Deno.errors.NotFound) {
32
+ return Deno.open(path, { createNew: true, write: true });
33
+ }
34
+ throw e;
35
+ }
36
+ }
37
+
26
38
  /**
27
39
  * Execute the Graphviz dot command and output the results to a file.
28
40
  */
29
41
  export async function toFile(dot, path, options) {
30
- const output = await Deno.open(path, { write: true });
42
+ const output = await open(path);
31
43
  const stream = await toStream(dot, options);
32
44
  await stream.pipeTo(output.writable);
33
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-graphviz",
3
- "version": "1.3.3-dev.dc36620d2",
3
+ "version": "1.3.4-dev.c1e4c50a9",
4
4
  "author": "kamiazya <yuki@kamiazya.tech>",
5
5
  "description": "Graphviz library for TypeScript.",
6
6
  "homepage": "https://ts-graphviz.github.io/ts-graphviz/",