1.3.0 • Published 5 years ago

node-shell-batcher v1.3.0

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

node-shell-batcher

A CLI for running batches of shell commands on folders.

How to Use

npx node-shell-batcher <path>

npx node-shell-batcher ./path/to/batch.js

npx node-shell-batcher ./path/to/batch.json

Batch File (required argument)

node-shell-batcher requires the path to a "batch" file, which must contain an array of objects. These objects will need to at least contain a path to a folder, and a command to run on each file in that folder.

OptionTypeRequiredDescription
commandString|Function|Array<String|Function>trueA string that represents a shell command, or a function that is passed the current filename and must return a string. An array of dependent strings or functions is also supported.
pathStringtruePath to folder where command will be run for each file.
filterFunctionfalsePassed into Array.prototype.filter to filter selected files in folder run for command.

Example Batch File

let batch = [
  {
    path: './path/to/folder',
    command: 'cat'
  },
  {
    path: './path/to/another/folder',
    command: filename => {
      return `cat "${filename}"`;
    }
  },
  {
    path: './path/to/yet/another/folder',
    command: 'cat',
    filter: filename => {
      return filename.endsWith('.txt');
    }
  },
  {
    path: './path/to/folder2',
    command: [
      'cat',
      'cat',
      filename => {
        return `cat "${filename}"`;
      }
    ]
  }
];

module.exports = batch;

Additional Options

OptionShort FlagRequiredDescription
--version-vfalseOutput the version number.
--help-hfalseOutput usage information.
1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago