Skip to content

Commit d7b1ebd

Browse files
fix: fix a bug in ensureFile when creating a file
1 parent cb8eb31 commit d7b1ebd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/core/fs/ensure.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ export async function ensureFile(
5555
encoding: 'utf-8',
5656
mode: options?.fileMode,
5757
});
58+
return;
5859
} else {
5960
throw new Error(
6061
`[path-nice] .ensureFile(): ${dirname} already exists and is not a directory.`,
6162
);
6263
}
6364
}
64-
6565
if (stats.isFile()) return;
6666
throw new Error(
6767
'[path-nice] .ensureFile(): the path already exists and is not a file.',
@@ -95,6 +95,7 @@ export function ensureFileSync(
9595
}
9696
if (parentStats.isDirectory()) {
9797
fs.writeFileSync(target, '', { encoding: 'utf-8', mode: options?.fileMode });
98+
return;
9899
} else {
99100
throw new Error(
100101
`[path-nice] .ensureFileSync(): ${dirname} already exists and is not ` +

src/core/path.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export function genPath(lowpath: PlatformPath, fs: FileSystem): PathFn {
4747
path.PathNiceArr = _PathNiceArr;
4848

4949
// No need to bind. All methods of `path` do not use `this`.
50-
// Assign values manually one by one, otherwise the JSDoc will not be inherited.
5150
path.normalize = lowpath.normalize;
5251
path.join = lowpath.join;
5352
path.resolve = lowpath.resolve;

0 commit comments

Comments
 (0)