Comparing version 0.0.6 to 0.0.7
54
index.js
@@ -31,6 +31,2 @@ /* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
my_fs.rmdir = dirname => promise_wrapper((resolve, reject) => { | ||
fs.rmdir(dirname, err => err ? reject(err) : resolve()); | ||
}); | ||
my_fs.unlink = filepath => promise_wrapper((resolve, reject) => { | ||
@@ -124,27 +120,23 @@ fs.unlink(filepath, err => { | ||
const _rmdir = dirname => promise_wrapper((resolve, reject) => { | ||
fs.readdir(dirname, async function _rmdir (err, files) { | ||
if (err) return reject(err); | ||
my_fs.readdir = dirpath => promise_wrapper((resolve, reject) => { | ||
fs.readdir(dirpath, (err, files) => err ? reject(err) : resolve(files)); | ||
}); | ||
try { | ||
for (const file of files) { | ||
const filepath = path.join(dirname, file); | ||
if (await my_fs.is_directory(filepath)) { | ||
await _rmdir(filepath); | ||
} else { | ||
await my_fs.unlink(filepath); | ||
} | ||
const _rmdir = dirpath => promise_wrapper(async (resolve, reject) => { | ||
try { | ||
const files = await my_fs.readdir(dirpath); | ||
for (const file of files) { | ||
const filepath = path.join(dirpath, file); | ||
if (await my_fs.is_directory(filepath)) { | ||
await _rmdir(filepath); | ||
} else { | ||
await my_fs.unlink(filepath); | ||
} | ||
await my_fs.rmdir(dirname); | ||
} catch (e) { | ||
err = e; | ||
} finally { | ||
return err ? reject(err) : resolve(); | ||
} | ||
}); | ||
}); | ||
my_fs.readdir = dirname => promise_wrapper((resolve, reject) => { | ||
fs.readdir(dirname, (err, files) => err ? reject(err) : resolve(files)); | ||
await my_fs.rmdir(dirpath); | ||
resolve(); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
@@ -156,2 +148,6 @@ | ||
my_fs.rmdir = dirpath => promise_wrapper((resolve, reject) => { | ||
fs.rmdir(dirpath, err => err ? reject(err) : resolve()); | ||
}); | ||
my_fs.remove_dir = async_wrapper(async dirpath => { | ||
@@ -163,3 +159,5 @@ try { | ||
} else { | ||
throw new Error(`dirpath: '${dirpath}' is not a directory`); | ||
const error = new Error("ENOTDIR"); | ||
error.code = "ENOTDIR"; | ||
throw error; | ||
} | ||
@@ -171,4 +169,4 @@ } catch (e) { | ||
my_fs.ensure_dir = dirpath => async_wrapper(async () => { | ||
await fs.mkdir(dirpath, {recursive: true}); | ||
my_fs.ensure_dir = async_wrapper(async dirpath => { | ||
await my_fs.mkdir(dirpath, {recursive: true}); | ||
}); | ||
@@ -175,0 +173,0 @@ |
{ | ||
"name": "@jeefo/fs", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "https://github.com/je3f0o/fs", | ||
@@ -5,0 +5,0 @@ "copyright": "2020", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7680
157