Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit af6fb31

Browse files
committed
Create file when validating logging.file path is writable.
1 parent cd17afb commit af6fb31

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/chains/ethereum/options/src/logging-options.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { normalize } from "./helpers";
22
import { Definitions } from "@ganache/options";
3-
import { promises, openSync, closeSync } from "fs";
3+
import { promises, writeFileSync } from "fs";
44
const open = promises.open;
55
import { format } from "util";
66

@@ -115,10 +115,9 @@ export const LoggingOptions: Definitions<LoggingConfig> = {
115115
},
116116
file: {
117117
normalize: rawInput => {
118-
// this will throw if the file is not writable
118+
// this will throw if the file is not writable, and creates the log file for later appending
119119
try {
120-
const fh = openSync(rawInput, "a");
121-
closeSync(fh);
120+
writeFileSync(rawInput, Buffer.alloc(0));
122121
} catch (err) {
123122
throw new Error(
124123
`Failed to write logs to ${rawInput}. Please check if the file path is valid and if the process has write permissions to the directory.`

0 commit comments

Comments
 (0)