Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meteor-it/fs

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meteor-it/fs - npm Package Compare versions

Comparing version 1.1.8 to 1.2.0

9

index.d.ts

@@ -23,4 +23,8 @@ /// <reference types="node" />

}>;
declare type IWalkOptions = {
filter?: (name: string) => boolean;
};
export declare function copy(from: string, to: string, options?: IWalkOptions): Promise<void>;
export declare function mkdir(pathStr: string, recursive?: boolean): Promise<void>;
export declare function unlink(pathStr: string, recursive?: boolean): Promise<void>;
export declare function unlink(pathStr: string, recursive?: boolean, options?: IWalkOptions): Promise<void>;
/**

@@ -35,3 +39,4 @@ * Write text to file

*/
export declare function walkDir(dir: string, cb?: (file: string, dir: string) => void): Promise<string[] | null>;
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>;
/**

@@ -38,0 +43,0 @@ * Check if file exists

@@ -45,2 +45,15 @@ import fsNative from 'fs';

}
export async function copy(from, to, options) {
from = path.resolve(from);
to = path.resolve(to);
console.log(from, to);
if ((await isDirectory(from))) {
const dirStruct = (await walkDirStruct(from)).map(e => e.replace(from, to));
await asyncEach(dirStruct, dir => mkdir(dir, true));
await asyncEach(await walkDir(from), f => options && options.filter && !options.filter(f) && Promise.resolve(true) || copy(f, f.replace(from, to)));
return;
}
await fsNative.promises.copyFile(from, to);
}
copy('node_modules', 'node_new_modules');
export async function mkdir(pathStr, recursive = false) {

@@ -51,3 +64,2 @@ pathStr = path.resolve(pathStr);

// check for availability of them
// TODO: Avoid recursion
try {

@@ -74,8 +86,17 @@ return await mkdir(pathStr);

}
export async function unlink(pathStr, recursive = false) {
async function unlinkDirectoryStructure(pathStr) {
pathStr = path.resolve(pathStr);
const dirs = await readDir(pathStr);
await asyncEach(dirs, async (dir) => {
const dirPath = path.resolve(pathStr, dir);
await unlinkDirectoryStructure(dirPath);
await unlink(dirPath);
});
}
export async function unlink(pathStr, recursive = false, options) {
pathStr = path.resolve(pathStr);
if (recursive) {
// Empty all dirs
await walkDir(pathStr).then(files => Promise.all(files.map((n) => unlink(n))));
// TODO: Remove empty directories
await walkDir(pathStr, options).then(files => Promise.all(files.map((n) => unlink(n))));
await unlinkDirectoryStructure(pathStr);
}

@@ -100,3 +121,3 @@ else {

*/
export async function walkDir(dir, cb) {
export async function walkDir(dir, options, cb) {
if (!await exists(dir)) {

@@ -110,4 +131,4 @@ throw new Error('No such file or directory: ' + dir);

shouldReturn = true;
cb = (file, dir) => {
returnValue.push(dir + path.sep + file);
cb = (file) => {
returnValue.push(path.resolve(dir, file));
};

@@ -119,3 +140,5 @@ }

if (await isFile(pathStr)) {
cb(file, dir);
if (options && options.filter && !options.filter(pathStr))
return;
cb(pathStr);
}

@@ -127,3 +150,3 @@ else if (await isDirectory(pathStr)) {

await asyncEach(dirList, async (dirLevelDown) => {
await walkDir(dir + path.sep + dirLevelDown, cb);
await walkDir(dir + path.sep + dirLevelDown, options, cb);
});

@@ -135,2 +158,34 @@ if (shouldReturn) {

}
export async function walkDirStruct(dir, options, cb) {
if (!await exists(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 = [];
await asyncEach(await readDir(dir), async (file) => {
let pathStr = path.resolve(dir, file);
if (await isDirectory(pathStr)) {
dirList.push(pathStr);
}
});
await asyncEach(dirList, async (dirLevelDown) => {
const dirPath = path.resolve(dir, dirLevelDown);
await walkDirStruct(dirPath, options, cb);
if (options && options.filter && !options.filter(dirPath))
return;
cb(dirPath);
});
if (shouldReturn) {
return returnValue.sort();
}
return null;
}
/**

@@ -175,2 +230,2 @@ * Check if file exists

//# sourceMappingURL=data:application/json;char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vbGVhbj4ge1xuXHRyZXR1cm4gKGF3YWl0IHN0YXQocGF0aCkpLmlzRGlyZWN0b3J5KCk7XG59XG5cbi8qKlxuICogV3JhcHBlciB0byBmcyBmdW5jdGlvblxuICovXG5leHBvcnQgZnVuY3Rpb24gZ2V0UmVhZFN0cmVhbShwYXRoOiBzdHJpbmcsIG9wdGlvbnMgPSB7fSkge1xuXHRyZXR1cm4gZnNOYXRpdmUuY3JlYXRlUmVhZFN0cmVhbShwYXRoLCBvcHRpb25zKTtcbn1cblxuLyoqXG4gKiBXcmFwcGVyIHRvIGZzIGZ1bmN0aW9uXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBnZXRXcml0ZVN0cmVhbShwYXRoOiBzdHJpbmcsIG9wdGlvbnMgPSB7fSkge1xuXHRyZXR1cm4gZnNOYXRpdmUuY3JlYXRlV3JpdGVTdHJlYW0ocGF0aCwgb3B0aW9ucyk7XG59XG4iXX0=

@@ -57,2 +57,21 @@ import fsNative, { Stats } from 'fs';

type IWalkOptions = {
filter?: (name: string) => boolean;
}
export async function copy(from: string, to: string, options?: IWalkOptions) {
from = path.resolve(from);
to = path.resolve(to);
console.log(from, to);
if ((await isDirectory(from))) {
const dirStruct = (await walkDirStruct(from)).map(e => e.replace(from, to));
await asyncEach(dirStruct, dir => mkdir(dir, true));
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)));
return;
}
await fsNative.promises.copyFile(from, to);
}
copy('node_modules', 'node_new_modules');
export async function mkdir(pathStr: string, recursive: boolean = false): Promise<void> {

@@ -63,3 +82,2 @@ pathStr = path.resolve(pathStr);

// check for availability of them
// TODO: Avoid recursion
try {

@@ -83,8 +101,17 @@ return await mkdir(pathStr);

export async function unlink(pathStr: string, recursive: boolean = false) {
async function unlinkDirectoryStructure(pathStr: string) {
pathStr = path.resolve(pathStr);
const dirs = await readDir(pathStr);
await asyncEach(dirs, async dir => {
const dirPath = path.resolve(pathStr, dir);
await unlinkDirectoryStructure(dirPath);
await unlink(dirPath);
});
}
export async function unlink(pathStr: string, recursive: boolean = false, options?: IWalkOptions) {
pathStr = path.resolve(pathStr);
if (recursive) {
// Empty all dirs
await walkDir(pathStr).then(files => Promise.all(files.map((n) => unlink(n))));
// TODO: Remove empty directories
await walkDir(pathStr, options).then(files => Promise.all(files.map((n) => unlink(n))));
await unlinkDirectoryStructure(pathStr);
} else {

@@ -110,3 +137,3 @@ if (await isDirectory(pathStr)) {

*/
export async function walkDir(dir: string, cb?: (file: string, dir: string) => void): Promise<string[] | null> {
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); }

@@ -118,4 +145,4 @@ let returnValue: string[];

shouldReturn = true;
cb = (file: string, dir: string) => {
returnValue.push(dir + path.sep + file);
cb = (file: string) => {
returnValue.push(path.resolve(dir, file));
};

@@ -127,3 +154,4 @@ }

if (await isFile(pathStr)) {
cb(file, dir);
if (options && options.filter && !options.filter(pathStr)) return;
cb(pathStr);
} else if (await isDirectory(pathStr)) {

@@ -134,3 +162,3 @@ dirList.push(file);

await asyncEach(dirList, async (dirLevelDown: string) => {
await walkDir(dir + path.sep + dirLevelDown, cb);
await walkDir(dir + path.sep + dirLevelDown, options, cb);
});

@@ -143,2 +171,32 @@ if (shouldReturn) {

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);
};
}
let dirList: string[] = [];
await asyncEach(await readDir(dir), async (file: string) => {
let pathStr = path.resolve(dir, file);
if (await isDirectory(pathStr)) {
dirList.push(pathStr);
}
});
await asyncEach(dirList, async (dirLevelDown: string) => {
const dirPath = path.resolve(dir, dirLevelDown);
await walkDirStruct(dirPath, options, cb);
if (options && options.filter && !options.filter(dirPath)) return;
cb(dirPath);
});
if (shouldReturn) {
return returnValue.sort();
}
return null;
}
/**

@@ -145,0 +203,0 @@ * Check if file exists

{
"name": "@meteor-it/fs",
"version": "1.1.8",
"version": "1.2.0",
"description": "Wrappers for native fs module",

@@ -20,3 +20,3 @@ "module": "index.mjs",

},
"gitHead": "1d959519c624e54df90813aac68afdddc1d1fc8a"
"gitHead": "9671934d578249a12c4dffaacf04dfb92ce8a167"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc