From 6cba1a91d8ad7d8bae9e3b2737f5d41c2daa9c00 Mon Sep 17 00:00:00 2001 From: segayuu Date: Wed, 15 Jan 2020 17:03:17 +0900 Subject: [PATCH] Inline checkParentSync function --- lib/fs.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index ebc17c7..11d1f98 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -52,12 +52,6 @@ function checkParent(path) { return Promise.resolve(fsPromises.mkdir(dirname(path), { recursive: true })); } -function checkParentSync(path) { - if (!path) throw new TypeError('path is required!'); - - fs.mkdirSync(dirname(path), { recursive: true }); -} - function writeFile(path, data, options, callback) { if (!path) throw new TypeError('path is required!'); @@ -72,7 +66,7 @@ function writeFile(path, data, options, callback) { function writeFileSync(path, data, options) { if (!path) throw new TypeError('path is required!'); - checkParentSync(path); + fs.mkdirSync(dirname(path), { recursive: true }); fs.writeFileSync(path, data, options); } @@ -90,7 +84,7 @@ function appendFile(path, data, options, callback) { function appendFileSync(path, data, options) { if (!path) throw new TypeError('path is required!'); - checkParentSync(path); + fs.mkdirSync(dirname(path), { recursive: true }); fs.appendFileSync(path, data, options); } @@ -438,7 +432,7 @@ function ensureWriteStream(path, options, callback) { function ensureWriteStreamSync(path, options) { if (!path) throw new TypeError('path is required!'); - checkParentSync(path); + fs.mkdirSync(dirname(path), { recursive: true }); return fs.createWriteStream(path, options); }