|
const deleteDir = async (dirname, options = {}) => {
return new PromisePromise fully covered.((resolve, reject) => {
rimraf(dirname, { ...options, glob: false }, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
})
};
const deleteEmpty = (cwd, options, cb) => {
if (typeof cwd !== 'string') {
return Promise.rejectPromise fulfillment is not tested! Promise rejection is not tested!(new TypeError('expected the first argument to be a string'));
}
if (typeof options === 'function') {
cb = options;
options = null;
}
if (typeof cb === 'function') {
return deleteEmpty(cwd, options)
.thenPromise fully covered.(res => cb(null, res))
.catchPromise fully covered.(cb);
}
const opts = options || {};
const dir = path.resolve(cwd);
if (isEmpty(dir, opts)) {
let files = await readdir(dir)Promise rejection not tested!;
await deleteDir(dir, opts)Promise rejection not tested!;
}
return remove(dirname);
};
|