action-walk
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -16,2 +16,3 @@ const fsp = require('fs').promises; | ||
} | ||
const stack = []; | ||
@@ -35,2 +36,3 @@ if (options.fileAction) { | ||
async function walker (dir) { | ||
stack.push(path.basename(dir)); | ||
for await (const dirent of await fsp.opendir(dir)) { | ||
@@ -42,3 +44,3 @@ let entry = path.join(dir, dirent.name); | ||
} | ||
const ctx = {dirent}; | ||
const ctx = {dirent, stack}; | ||
if (options.own) { | ||
@@ -66,2 +68,3 @@ ctx.own = options.own; | ||
} | ||
stack.pop(); | ||
return undefined; | ||
@@ -68,0 +71,0 @@ } |
{ | ||
"name": "action-walk", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "walk a directory tree performing actions", | ||
@@ -5,0 +5,0 @@ "main": "action-walk.js", |
@@ -47,11 +47,12 @@ # action-walk | ||
await walk('.', options); | ||
walk('.', options) | ||
.then(() => { | ||
console.log('total bytes in "."', ctx.total); | ||
}); | ||
console.log('total bytes in "."', ctx.total); | ||
// executed in the await-walk package root it will print something like | ||
// executed in the action-walk package root it will print something like | ||
// total bytes in "." 14778 | ||
``` | ||
see `test/basics.test.js` for another example. | ||
see `test/basics.test.js` or `bin/walk.js` for other examples. | ||
@@ -67,5 +68,5 @@ ### api | ||
- `otherAction` - called when the entry is not a file, directory, or symbolic link. | ||
- `stat` - if `lstat` call `fs.lstat` on the entry and add it to the action context. if | ||
otherwise truthy use `fs.stat`. | ||
- `own` - add this to the action context. it is context for the action functions. | ||
- `stat` - if `'lstat'` call `fs.lstat` on the entry and add it to the action context's `stat` | ||
property. if otherwise truthy use `fs.stat`. | ||
- `own` - add this to the action context. it is your context for the action functions. | ||
@@ -86,2 +87,3 @@ It's possible to call `walk()` with no options but probably not useful unless | ||
stat, // if `options.stat` the object returned by `fs.stat` or `fs.lstat` | ||
stack, // the stack of directories above the current dirent item. | ||
own // `options.own` if provided. | ||
@@ -88,0 +90,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
100
1
7087
4
99