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

foreach-cli

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

foreach-cli

CLI util to execute a command for each file matching a glob

1.8.1
latest
Source
npm
Version published
Weekly downloads
3.8K
-1.65%
Maintainers
1
Weekly downloads
 
Created
Source

foreach-cli

CLI utility to execute a command for each file matching a glob. Originally a fork of [each-cli][https://www.npmjs.com/package/each-cli], but then completely rewritten in order to provoke simplicity and eliminate annoying bugs. It differs form the original mainly by setting the CWD (current working directory) to the directory the foreach command was executed from, as opposed to the original package's behavior which set the CWD to the matched file's directory. It also takes the command arguments as strings to allow more complex commands such as piping.

Installation:

npm install foreach-cli

Usage:

Command Line

foreach -g <glob> -x <command to execute>

Command Line Options:

-g, --glob        Specify the glob
-i, --ignore      Glob ignore pattern(s)
-x, --execute     Command to execute upon file addition/change
-c, --forceColor  Force color TTY output (pass --no-c to disable)
-t, --trim        Trims the output of the command executions to only show the first X characters of the output
-C, --concurrent  Execute commands concurrently (pass --no-C to disable)
-h                Show help
--version         Show version number                                    

Executing Command Placeholders

"path"  -  full path and filename
"root"  -  file root
"dir"   -  path without the filename
"reldir"-  directory name of file relative to the glob provided
"base"  -  file name and extension
"ext"   -  just file extension
"name"  -  just file name

Example:

Command Line:

foreach -g "**/*.tar" -x "tar xvf #{path}"
foreach -g "*/*.jpg" -x "convert #{path}.jpg #{dir}/#{name}.converted.png"

Keywords

cli

FAQs

Package last updated on 28 Sep 2018

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