1.2.0 • Published 4 years ago

filetask-run v1.2.0

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

File Task runner

Simple tool to automate executing cli programs on multiple files which normally is done on single files.

It will take the command defined in your configuration, for example cat. It will execute a shell command for each file the glob finds. In a folder with 4 files, and glob folder/*, the following commands will be executed.

cat /fullpath/file1.ext
cat /fullpath/file2.ext
cat /fullpath/file3.ext
cat /fullpath/file4.ext

By default the output will not be shown, so cat is not the best usage. But if you want to make all shell scripts in some directory structure executable, the configured command could be chmod +x.

Usage

Global install
filetask test "./src/*.ts"
Local install
./node_modules/.bin/filetask run "./src/*.ts" true

By default the tool wil look for a taskConfig.json in the current and parent folders. Alternatively it can be passed using the -c flag.

commandargumentsdescription
testglobThis function will test your config, and list the commands that will be executed
runglob parallelCreates a shell command for each file found with the glob, and will execute it, can be run at the same time by passing true after the globPattern
helpList help

Configuration

{
    "command": "cat", // lefthand side of shell command that will be executed
    "advanced": "echo {full} \n echo {glob} \n echo {replaced}", 
    // if advanced is passed command will be ignored, using the variables you can compose where the path will show up in the generated command
    // full for the full path from the root
    // glob for the result of the glob, so the path relative to where filetask was exectued
    // replaced is the full path, passed through a replace function generated with the pattern and value described below 
    "taskVerbose": false, // If set to true, instead of a progress bar, the output of all commands will be executed
    "replacePattern": "/Users/exampleuser/projects/js/task-run/", // if set will try to replace this in the filepath to the replace value
    "replaceValue": "",
    "escapeSpace": true // if not set, will default to true, will escape all spaces ' ' to '\ ' in the commands that will be executed
}