@taskr/shell
Execute shell commands with Taskr
Last updated 3 years ago by lukeed .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @taskr/shell 
SYNC missed versions from official npm registry.

@taskr/shell npm

Execute shell commands with Taskr.

Install

$ npm install --save-dev @taskr/shell

API

.shell(command, [options])

Both parameters are optional, but at least one must be present. Additionally, a command is required

command

Type: string

The shell command to run. You may also use options.cmd

During execution, any occurrences of $file or $glob will be replaced with the the relevant filepath or glob pattern.

options

Type: object

@taskr/shell uses execa as its child_process wrapper. This means it has the same options as child_process.exec and shares execa's additional options.

options.cmd

Type: string

Same as command. You may want to use this if you only want to specify an options object.

options.glob

Type: boolean

If the command should use the glob pattern within task.source(), you must set this to true. See here for example.

Usage

Iterate Once Per File

You can apply a command to each file of your glob match.

Instances of $file will be replaced by the file's path.

exports.default = function * (task) {
  yield task.source('src/*.js')
    .shell('cat $file')
    //=> @taskr/shell: console.log('this is src/a.js')
    //=> @taskr/shell: console.log('this is src/b.js')
    //=> @taskr/shell: console.log('this is src/c.js')
    .dist('dist');
}

Iterate Once Per Glob

You can use the current glob within your shell command.

Instances of $file will be replaced by the glob:

exports.default = function * (task) {
  yield task.source('src/*.js')
    .shell('cat $file', { glob:true })
    //=> @taskr/shell:
    //=>     console.log('this is src/a.js')
    //=>     console.log('this is src/b.js')
    //=>     console.log('this is src/c.js')
    .dist('dist');

  yield task.source(['src/*.js', 'src/*.css'])
    .shell({
      cmd: 'cat $glob',
      glob: true
    })
    //=> @taskr/shell:
    //=>     console.log('this is src/a.js')
    //=>     console.log('this is src/b.js')
    //=>     console.log('this is src/c.js')
    //=>     body{margin:0;}header{color:black}
    //=>     .hero{width:100%;height:400px}
    .dist('dist');
}

Passing Arguments

Of course, command arguments may be passed within your command string.

exports.default = function * (task) {
  yield task.source('src').shell('ls -alh $file').dist('dist');
}

Support

Any issues or questions can be sent to the Taskr monorepo.

Please be sure to specify that you are using @taskr/shell.

License

MIT © Luke Edwards

Current Tags

  • 1.1.0                                ...           latest (3 years ago)

4 Versions

  • 1.1.0                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |