🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

findx-cli

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

findx-cli

CLI to find and execute command for every glob match

0.2.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

findx-cli

CLI to find and execute command for every glob match

Elegant replacement for each-cli, foreach-cli and *nix find -exec command in very little lines of code. Useful for NPM scripts or CI.

  • Cross-platform
  • Concurrency support
  • Continue on error, then exit with code 1
  • Control output of every execution
  • Automatically show task progress in TTY

Install

$ npm i -g findx-cli

Usage

$ findx '**/*.jpg' -- convert {{path}} {{dir}}/{{name}}.png

This searches for all files matching the glob pattern, then runs the provided command against each match.

See below for more usage examples.

Options

Usage: findx <globs> [options] -- [commands...]

CLI to find and execute command for every glob match

Arguments:
  globs                   globs to match
  commands                commands to execute

Options:
  -C, --concurrent <max>  concurrent number of executions (default: 10)
  --log <level>           log level (choices: "stdout", "stderr", "all",
                          "none", default: "all")
  --sh                    run each execution in new shell
  --cd                    change to path directory for each run
  -V, --version           output the version number
  -h, --help              display help for command

Command Templating

Write your command using mustache syntax. The following tags are exposed:

TagEgDesc
{{path}}/home/user/dir/file.txtFull path of file
{{root}}/Root
{{dir}}/home/user/dirDirectory portion
{{base}}file.txtFile name with extension
{{name}}fileName portion
{{ext}}.txtExtension portion

Examples

Untar each tar file in its own directory

$ findx '**/*.tar' --cd -- tar -xvf {{base}}

Ignore some files and run shell-specific commands

$ findx '**/LICENSE !ignored/**' --sh -- 'cd {{dir}} && cat LICENSE'

Dry-run glob matches

$ findx '**/*.{txt,xml}'

Development

Standard Github contribution workflow applies.

Tests

Test specs are in test/spec.js. To run the tests:

$ npm run test

License

ISC

Keywords

cli

FAQs

Package last updated on 09 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts