@bscotch/utility
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -26,2 +26,6 @@ export interface ListPathOptions { | ||
export declare function listFilesByExtensionSync(dir: string, extension: string | string[], recursive?: boolean, options?: ListPathOptions): string[]; | ||
/** | ||
* Find and delete all empty directories. | ||
*/ | ||
export declare function removeEmptyDirsSync(startDir: string): void; | ||
//# sourceMappingURL=files.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.listFilesByExtensionSync = exports.listFilesSync = exports.listFoldersSync = exports.listPathsSync = void 0; | ||
exports.removeEmptyDirsSync = exports.listFilesByExtensionSync = exports.listFilesSync = exports.listFoldersSync = exports.listPathsSync = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -75,2 +75,15 @@ const path_1 = __importDefault(require("path")); | ||
exports.listFilesByExtensionSync = listFilesByExtensionSync; | ||
/** | ||
* Find and delete all empty directories. | ||
*/ | ||
function removeEmptyDirsSync(startDir) { | ||
const folders = listFoldersSync(startDir, true); | ||
for (const folder of folders) { | ||
try { | ||
fs_1.default.rmdirSync(folder); | ||
} | ||
catch { } | ||
} | ||
} | ||
exports.removeEmptyDirsSync = removeEmptyDirsSync; | ||
//# sourceMappingURL=files.js.map |
@@ -0,1 +1,10 @@ | ||
# [0.5.0](https://github.com/bscotch/node-util/compare/v0.4.0...v0.5.0) (2020-10-12) | ||
### Features | ||
* Add method for finding and deleting empty folders. ([386b32d](https://github.com/bscotch/node-util/commit/386b32dac671386a931dd837bb08d70c78e53e35)) | ||
# [0.4.0](https://github.com/bscotch/node-util/compare/v0.3.1...v0.4.0) (2020-10-12) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "@bscotch/utility", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Bscotch Utilities: Methods for common Node.js needs.", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -114,2 +114,3 @@ # Bscotch Utilities | ||
listFilesByExtensionSync, | ||
removeEmptyDirsSync, | ||
} from '@bscotch/utility'; | ||
@@ -124,2 +125,3 @@ | ||
listFilesByExtensionSync('.',['txt','md'],recursive); // => the subset of files that end with '.txt' or '.md' | ||
removeEmptyDirsSync('.'); // Remove all empty directories (recursively) | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24585
274
126