fly-execa v1.0.0
fly-execa
Execute shell commands with Fly
Install
npm install --save-dev fly-execa
API
fly-execa
uses execa as its child_process
wrapper. This means it has the same options as child_process.exec and shares execa
's additional options.
.execa(command, options)
command
Type: string
Any occurrences of $file
will be replaced with the the relevant filepath or glob pattern.
options
Type: object
See child_process.exec and execa for more info.
options.glob
Type: boolean
If the command should use the glob pattern within source()
, you must set this to true
or 1
. 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 * () {
yield this.source('src/*.js')
.execa('cat $file')
//=> fly-execa: console.log('this is src/a.js')
//=> fly-execa: console.log('this is src/b.js')
//=> fly-execa: console.log('this is src/c.js')
.dist('dist');
}
Iterate Once Per Glob
You can use the current glob within your shell command.
Note: Currently, only one glob pattern is supported.
Instances of $file
will be replaced by the glob:
exports.default = function * () {
yield this.source('src/*.js')
.execa('cat $file', {glob: true})
//=> fly-execa:
//=> console.log('this is src/a.js')
//=> console.log('this is src/b.js')
//=> console.log('this is src/c.js')
.dist('dist');
}
Passing Arguments
Of course, command arguments may be passed within your command string.
exports.default = function * () {
yield this.source('src')
.execa('ls -alh $file', {glob: true})
.dist('dist');
}
License
MIT © Luke Edwards
8 years ago