Comparing version 1.7.0 to 1.8.0
@@ -11,2 +11,3 @@ /// <reference types="node" /> | ||
remove(sourcePath: string): Promise<void>; | ||
removeDir(directoryPath: string): Promise<void>; | ||
copy(src: string, dest: string): Promise<void>; | ||
@@ -13,0 +14,0 @@ write(sourcePath: string, content: string): Promise<void>; |
@@ -52,8 +52,2 @@ "use strict"; | ||
} | ||
// public async mkdir (sourcePath:string):Promise<void> { | ||
// const fullPath = this.resolve(sourcePath) | ||
// return new Promise<void>((resolve, reject) => { | ||
// fs.mkdir(fullPath, { recursive: true }, err => err ? reject(err) : resolve()) | ||
// }) | ||
// } | ||
resolve(source) { | ||
@@ -91,2 +85,24 @@ const _source = source.trim(); | ||
} | ||
removeDir(directoryPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const stats = yield this.lstat(directoryPath); | ||
if (!stats.isDirectory()) { | ||
yield this.remove(directoryPath); | ||
return; | ||
} | ||
const files = yield this.readdir(directoryPath); | ||
yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () { | ||
const filePath = path_1.default.join(directoryPath, file); | ||
yield this.removeDir(filePath); | ||
}))); | ||
return new Promise((resolve, reject) => { | ||
fs_1.default.rmdir(directoryPath, err => err ? reject(err) : resolve()); | ||
}); | ||
} | ||
catch (err) { | ||
console.error(`Error removing directory ${directoryPath}: ${err}`); | ||
} | ||
}); | ||
} | ||
copy(src, dest) { | ||
@@ -93,0 +109,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "h3lp", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Helper for nodeJs", | ||
@@ -5,0 +5,0 @@ "author": "Flavio Lionel Rita <flaviolrita@hotmail.com>", |
Sorry, the diff of this file is not supported yet
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
219018
2827