Skip to content

Commit

Permalink
Inline checkParentSync function
Browse files Browse the repository at this point in the history
  • Loading branch information
segayuu committed Jan 15, 2020
1 parent af69709 commit 6cba1a9
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/fs.js
Expand Up @@ -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!');

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 6cba1a9

Please sign in to comment.