@universal-packages/directory-traversal
Advanced tools
Comparing version 1.2.3 to 1.3.0
{ | ||
"name": "@universal-packages/directory-traversal", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "Simple tool to traverse a directory deeply and get desired info", | ||
@@ -15,3 +15,4 @@ "author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)", | ||
"test:clear": "jest --clearCache", | ||
"format": "prettier --write \"./{src,tests}/**/*.{ts,tsx,js,jsx,json}\"" | ||
"format": "prettier --write \"./{src,tests}/**/*.{ts,tsx,js,jsx,json}\"", | ||
"update-dependents": "umaintenance update-dependents" | ||
}, | ||
@@ -22,17 +23,13 @@ "dependencies": { | ||
"devDependencies": { | ||
"@trivago/prettier-plugin-sort-imports": "^4.1.1", | ||
"@types/jest": "^28.1.0", | ||
"@types/node": "^17.0.39", | ||
"jest": "^28.1.0", | ||
"jest-circus": "^28.1.0", | ||
"prettier": "^2.8.7", | ||
"ts-jest": "^28.0.4", | ||
"typescript": "^4.7.3" | ||
"@trivago/prettier-plugin-sort-imports": "^4.2.0", | ||
"@types/jest": "^29.5.5", | ||
"@types/node": "^18.11.9", | ||
"@universal-packages/maintenance": "^1.2.4", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.0.3", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.2.2" | ||
}, | ||
"jest": { | ||
"testRunner": "jest-circus/runner", | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
"testRegex": "(/tests/.*\\.test\\.ts?)$", | ||
"preset": "ts-jest", | ||
"collectCoverageFrom": [ | ||
@@ -42,6 +39,3 @@ "src/**/*.ts" | ||
"setupFilesAfterEnv": [ | ||
"<rootDir>/tests/setupTests.ts" | ||
], | ||
"watchPathIgnorePatterns": [ | ||
"<rootDir>/tmp" | ||
"<rootDir>/tests/setup.ts" | ||
] | ||
@@ -54,2 +48,5 @@ }, | ||
"trailingComma": "none", | ||
"plugins": [ | ||
"@trivago/prettier-plugin-sort-imports" | ||
], | ||
"importOrder": [ | ||
@@ -56,0 +53,0 @@ "^[./]" |
@@ -9,2 +9,2 @@ import { DirectoryMap, DirectoryTraversalOptions } from './traverse.types'; | ||
*/ | ||
export declare function traverse(location: string, options?: DirectoryTraversalOptions): Promise<DirectoryMap>; | ||
export declare function traverse(location: string, options?: DirectoryTraversalOptions): DirectoryMap; |
@@ -17,6 +17,6 @@ "use strict"; | ||
*/ | ||
async function traverse(location, options = {}) { | ||
function traverse(location, options = {}) { | ||
const finalLocation = (0, fs_utils_1.checkDirectory)(location); | ||
const root = { path: finalLocation, basename: path_1.default.basename(finalLocation), files: [], directories: [] }; | ||
await recursiveTraverse(root, 0, options); | ||
recursiveTraverse(root, 0, options); | ||
return root; | ||
@@ -26,3 +26,3 @@ } | ||
/** Recursively go through directory trees */ | ||
async function recursiveTraverse(root, level, options) { | ||
function recursiveTraverse(root, level, options) { | ||
let rawFiles; | ||
@@ -80,3 +80,3 @@ const directories = []; | ||
// We only go deeper if the callback is true | ||
const shouldContinue = await options.callback(root); | ||
const shouldContinue = options.callback(root); | ||
if (!shouldContinue) | ||
@@ -93,5 +93,5 @@ return; | ||
const nextDirectory = root.directories[i]; | ||
await recursiveTraverse(nextDirectory, level + 1, options); | ||
recursiveTraverse(nextDirectory, level + 1, options); | ||
} | ||
} | ||
//# sourceMappingURL=traverse.js.map |
@@ -1,2 +0,2 @@ | ||
export declare type TraverseCallback = (directoryMap: DirectoryMap) => boolean | Promise<boolean>; | ||
export type TraverseCallback = (directoryMap: DirectoryMap) => boolean; | ||
export interface DirectoryTraversalOptions { | ||
@@ -3,0 +3,0 @@ callback?: TraverseCallback; |
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
14648