@meteor-it/fs
Advanced tools
Comparing version 1.2.14 to 1.2.16
@@ -33,9 +33,11 @@ /// <reference types="node" /> | ||
export declare function writeFile(filename: string, text: string | Buffer): Promise<void>; | ||
export declare function walkDirArray(dir: string, options?: IWalkOptions): Promise<string[]>; | ||
/** | ||
* Walk directory | ||
* @param dir Directory to walk | ||
* @param cb If provided, found files will returned realtime. If not - function will return all found files | ||
* @param dir directory to walk | ||
* @param cb found files will returned realtime | ||
*/ | ||
export declare function walkDir(dir: string, options?: IWalkOptions, cb?: (file: string) => void): Promise<string[] | null>; | ||
export declare function walkDirStruct(dir: string, options?: IWalkOptions, cb?: (dir: string) => void): Promise<string[] | null>; | ||
export declare function walkDir(dir: string, cb?: (file: string) => void, options?: IWalkOptions): Promise<void>; | ||
export declare function walkDirStructArray(dir: string, options?: IWalkOptions): Promise<string[]>; | ||
export declare function walkDirStruct(dir: string, cb: (dir: string) => void, options?: IWalkOptions): Promise<void>; | ||
/** | ||
@@ -42,0 +44,0 @@ * Check if file exists |
73
index.js
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const utils_1 = require("@meteor-it/utils"); | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
/** | ||
@@ -59,3 +56,3 @@ * Returns true if path is a valid data url | ||
if ((await isDirectory(from))) { | ||
const dirStruct = (await walkDirStruct(from)).map(e => e.replace(from, to)); | ||
const dirStruct = (await walkDirStructArray(from)).map(e => e.replace(from, to)); | ||
try { | ||
@@ -66,3 +63,3 @@ await utils_1.asyncEach(dirStruct, dir => mkdir(dir, true)); | ||
try { | ||
await utils_1.asyncEach(await walkDir(from), f => options && options.filter && !options.filter(f) && Promise.resolve(true) || copy(f, f.replace(from, to))); | ||
await utils_1.asyncEach(await walkDirArray(from), f => options && options.filter && !options.filter(f) && Promise.resolve(true) || copy(f, f.replace(from, to))); | ||
} | ||
@@ -118,3 +115,3 @@ catch (e) { | ||
// Empty all dirs | ||
await walkDir(pathStr, options).then(files => Promise.all(files.map((n) => unlink(n)))); | ||
await walkDirArray(pathStr, options).then(files => Promise.all(files.map((n) => unlink(n)))); | ||
await unlinkDirectoryStructure(pathStr); | ||
@@ -137,20 +134,15 @@ } | ||
exports.writeFile = writeFile; | ||
function walkDirArray(dir, options) { | ||
return utils_1.collectCallbacks(collector => walkDir(dir, collector, options)); | ||
} | ||
exports.walkDirArray = walkDirArray; | ||
/** | ||
* Walk directory | ||
* @param dir Directory to walk | ||
* @param cb If provided, found files will returned realtime. If not - function will return all found files | ||
* @param dir directory to walk | ||
* @param cb found files will returned realtime | ||
*/ | ||
async function walkDir(dir, options, cb) { | ||
async function walkDir(dir, cb, options) { | ||
if (!await exists(dir)) { | ||
throw new Error('No such file or directory: ' + dir); | ||
throw new Error('no such file or directory: ' + dir); | ||
} | ||
let returnValue; | ||
let shouldReturn = false; | ||
if (!cb) { | ||
returnValue = []; | ||
shouldReturn = true; | ||
cb = (file) => { | ||
returnValue.push(path_1.default.resolve(dir, file)); | ||
}; | ||
} | ||
let dirList = []; | ||
@@ -160,5 +152,5 @@ await utils_1.asyncEach(await readDir(dir), async (file) => { | ||
if (await isFile(pathStr)) { | ||
if (options && options.filter && !options.filter(pathStr)) | ||
if (options?.filter && !options.filter(pathStr)) | ||
return; | ||
cb(pathStr); | ||
cb?.(pathStr); | ||
} | ||
@@ -170,23 +162,14 @@ else if (await isDirectory(pathStr)) { | ||
await utils_1.asyncEach(dirList, async (dirLevelDown) => { | ||
await walkDir(dir + path_1.default.sep + dirLevelDown, options, cb); | ||
await walkDir(dir + path_1.default.sep + dirLevelDown, cb, options); | ||
}); | ||
if (shouldReturn) { | ||
return returnValue.sort(); | ||
} | ||
return null; | ||
} | ||
exports.walkDir = walkDir; | ||
async function walkDirStruct(dir, options, cb) { | ||
function walkDirStructArray(dir, options) { | ||
return utils_1.collectCallbacks(collector => walkDirStruct(dir, collector, options)); | ||
} | ||
exports.walkDirStructArray = walkDirStructArray; | ||
async function walkDirStruct(dir, cb, options) { | ||
if (!await exists(dir)) { | ||
throw new Error('No such file or directory: ' + dir); | ||
throw new Error('no such file or directory: ' + dir); | ||
} | ||
let returnValue; | ||
let shouldReturn = false; | ||
if (!cb) { | ||
returnValue = []; | ||
shouldReturn = true; | ||
cb = (dir) => { | ||
returnValue.push(dir); | ||
}; | ||
} | ||
let dirList = []; | ||
@@ -201,11 +184,7 @@ await utils_1.asyncEach(await readDir(dir), async (file) => { | ||
const dirPath = path_1.default.resolve(dir, dirLevelDown); | ||
await walkDirStruct(dirPath, options, cb); | ||
if (options && options.filter && !options.filter(dirPath)) | ||
await walkDirStruct(dirPath, cb, options); | ||
if (options?.filter && !options.filter(dirPath)) | ||
return; | ||
cb(dirPath); | ||
cb?.(dirPath); | ||
}); | ||
if (shouldReturn) { | ||
return returnValue.sort(); | ||
} | ||
return null; | ||
} | ||
@@ -257,2 +236,2 @@ exports.walkDirStruct = walkDirStruct; | ||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInhyZXN0L25vZGVfbW9kdWxlcy9AbWV0ZW9yLWl0L2ZzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsNENBQXFDO0FBQ3JDLGdEQUF3QjtBQUN4Qiw0Q0FBNkM7QUFHN0M7OztHQUdHO0FBQ0gsU0FBUyxTQUFTLENBQUMsSUFBWTtJQUM5QixPQUFPLHNCQUFzQixDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsRUFBRSxHQUFHLENBQUMsQ0FBQyxDQUFBO0FBQ3hELENBQUM7QUFNRDs7O0dBR0c7QUFDSCxTQUFTLFlBQVksQ0FBQyxJQUFZO0lBQ2pDLE9BQU87UUFDTixJ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bnMpO1xufVxuXG4vKipcbiAqIFdyYXBwZXIgdG8gZnMgZnVuY3Rpb25cbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIGdldFdyaXRlU3RyZWFtKHBhdGg6IHN0cmluZywgb3B0aW9ucyA9IHt9KSB7XG5cdHJldHVybiBmc05hdGl2ZS5jcmVhdGVXcml0ZVN0cmVhbShwYXRoLCBvcHRpb25zKTtcbn1cbiJdfQ== |
66
index.ts
@@ -0,4 +1,4 @@ | ||
import { asyncEach, collectCallbacks } from '@meteor-it/utils'; | ||
import fsNative, { Stats } from 'fs'; | ||
import path from 'path'; | ||
import { asyncEach } from '@meteor-it/utils'; | ||
@@ -65,3 +65,3 @@ type FileHandle = fsNative.promises.FileHandle; | ||
if ((await isDirectory(from))) { | ||
const dirStruct = (await walkDirStruct(from)).map(e => e.replace(from, to)); | ||
const dirStruct = (await walkDirStructArray(from)).map(e => e.replace(from, to)); | ||
try { | ||
@@ -71,3 +71,3 @@ await asyncEach(dirStruct, dir => mkdir(dir, true)); | ||
try { | ||
await asyncEach(await walkDir(from), f => options && options.filter && !options.filter(f) && Promise.resolve(true) as any as Promise<void> || copy(f, f.replace(from, to))); | ||
await asyncEach(await walkDirArray(from), f => options && options.filter && !options.filter(f) && Promise.resolve(true) as any as Promise<void> || copy(f, f.replace(from, to))); | ||
} catch (e) { | ||
@@ -117,3 +117,3 @@ if (e.code !== 'ENOENT') throw e; | ||
// Empty all dirs | ||
await walkDir(pathStr, options).then(files => Promise.all(files.map((n) => unlink(n)))); | ||
await walkDirArray(pathStr, options).then(files => Promise.all(files.map((n) => unlink(n)))); | ||
await unlinkDirectoryStructure(pathStr); | ||
@@ -135,18 +135,14 @@ } else { | ||
export function walkDirArray(dir: string, options?: IWalkOptions): Promise<string[]> { | ||
return collectCallbacks(collector => walkDir(dir, collector, options)); | ||
} | ||
/** | ||
* Walk directory | ||
* @param dir Directory to walk | ||
* @param cb If provided, found files will returned realtime. If not - function will return all found files | ||
* @param dir directory to walk | ||
* @param cb found files will returned realtime | ||
*/ | ||
export async function walkDir(dir: string, options?: IWalkOptions, cb?: (file: string) => void): Promise<string[] | null> { | ||
if (!await exists(dir)) { throw new Error('No such file or directory: ' + dir); } | ||
let returnValue: string[]; | ||
let shouldReturn = false; | ||
if (!cb) { | ||
returnValue = []; | ||
shouldReturn = true; | ||
cb = (file: string) => { | ||
returnValue.push(path.resolve(dir, file)); | ||
}; | ||
} | ||
export async function walkDir(dir: string, cb?: (file: string) => void, options?: IWalkOptions): Promise<void> { | ||
if (!await exists(dir)) { throw new Error('no such file or directory: ' + dir); } | ||
let dirList: string[] = []; | ||
@@ -156,4 +152,4 @@ await asyncEach(await readDir(dir), async (file: string) => { | ||
if (await isFile(pathStr)) { | ||
if (options && options.filter && !options.filter(pathStr)) return; | ||
cb(pathStr); | ||
if (options?.filter && !options.filter(pathStr)) return; | ||
cb?.(pathStr); | ||
} else if (await isDirectory(pathStr)) { | ||
@@ -164,21 +160,11 @@ dirList.push(file); | ||
await asyncEach(dirList, async (dirLevelDown: string) => { | ||
await walkDir(dir + path.sep + dirLevelDown, options, cb); | ||
await walkDir(dir + path.sep + dirLevelDown, cb, options); | ||
}); | ||
if (shouldReturn) { | ||
return returnValue.sort(); | ||
} | ||
return null; | ||
} | ||
export async function walkDirStruct(dir: string, options?: IWalkOptions, cb?: (dir: string) => void): Promise<string[] | null> { | ||
if (!await exists(dir)) { throw new Error('No such file or directory: ' + dir); } | ||
let returnValue: string[]; | ||
let shouldReturn = false; | ||
if (!cb) { | ||
returnValue = []; | ||
shouldReturn = true; | ||
cb = (dir: string) => { | ||
returnValue.push(dir); | ||
}; | ||
} | ||
export function walkDirStructArray(dir: string, options?: IWalkOptions): Promise<string[]> { | ||
return collectCallbacks(collector => walkDirStruct(dir, collector, options)); | ||
} | ||
export async function walkDirStruct(dir: string, cb: (dir: string) => void, options?: IWalkOptions): Promise<void> { | ||
if (!await exists(dir)) { throw new Error('no such file or directory: ' + dir); } | ||
let dirList: string[] = []; | ||
@@ -193,10 +179,6 @@ await asyncEach(await readDir(dir), async (file: string) => { | ||
const dirPath = path.resolve(dir, dirLevelDown); | ||
await walkDirStruct(dirPath, options, cb); | ||
if (options && options.filter && !options.filter(dirPath)) return; | ||
cb(dirPath); | ||
await walkDirStruct(dirPath, cb, options); | ||
if (options?.filter && !options.filter(dirPath)) return; | ||
cb?.(dirPath); | ||
}); | ||
if (shouldReturn) { | ||
return returnValue.sort(); | ||
} | ||
return null; | ||
} | ||
@@ -203,0 +185,0 @@ |
{ | ||
"name": "@meteor-it/fs", | ||
"version": "1.2.14", | ||
"version": "1.2.16", | ||
"description": "Wrappers for native fs module", | ||
@@ -14,3 +14,3 @@ "module": "index.mjs", | ||
"dependencies": { | ||
"@meteor-it/utils": "^1.3.27" | ||
"@meteor-it/utils": "^1.3.29" | ||
}, | ||
@@ -21,3 +21,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "7b240cacfacfe9f46c45796028c518753cc6f6b1" | ||
"gitHead": "45ae37da49e836f0d90dc0a0a395e500fc2f6f1b" | ||
} |
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
59904
837
Updated@meteor-it/utils@^1.3.29