1.0.0 • Published 8 years ago

tree-exec v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Tree exec

Node.js cli utility that walks a path and executes a command for each file on the path.

Motivation

Trying to use NPM as a build tool can be complicated in windows, the biggest problem beeing the shell don't expand glob patterns, so some utilities need a for loop to work properly, to aid with interop this package was developed.

Basic usage

$ tree-exec [options] <command>

Examples:

$ tree-exec -a command @f
$ tree-exec -g="./**/*.ext" command @f
$ tree-exec -r="[^node_modules]\/.*$" command @f

Options:

Parameter:Description:
-h, --helpShow this information.
-p, --pathThe base path to start the search, if it is different from the current working directory.
-d, --depthSets the depth to search.
-g, --globA glob pattern to use as search.
-r, --regexA RegExp pattern to use as search.
-a, --allSearch throug all files.
-i, --icaseSet case insensitiveness of the search.
-x, --dotSets if it should include paths starting with ..
-l, --librarySets if it should include library paths like node_modules or bower_components.
-u, --unicodeSet the unicode flag. NOTE: Only use if your node version supports it, or it will give wrong results.
-s, --globstarDisable ** matching against multiple folder names.
-c, --nocomentSuppress the behavior of treating # at the start of a pattern as a comment.
-n, --nonegateSuppress the behavior of treating a leading ! character as negation.
-e, --noextDisable "extglob" style patterns like +(a¦b).
-b, --nobraceDo not expand {a,b} and {1..3} brace sets.
-m, --mathbaseIf set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, a?b would match the path /xyz/123/acb, but not /xyz/acb/123.

Replace options

The following options can be used after @:

OptionResultExample
fThe path, name and extension of the file../dir/file.ext
nThe name of the file.file
eThe extension of the file (with dot)..ext
rThe relative path of the file../dir/
pThe full path of the file./home/user/dir/
sThe file size (in human redable format).1KB
zThe file size (in bytes).1024
mThe file's last modified timestamp.2016116043022876
tThe file's creation timestamp.2016116043022876

If the options are preceeded by a ~ then the path will be unquoted. Eg.: @~f will produce ./dir/file.ext

TODO

  • Test against git bash and other *nix shells for completeness.
  • Add attributes flag to file.