Socket
Book a DemoInstallSign in
Socket

fly-shell

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fly-shell

Execute shell commands with Fly

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
Created
Source

fly-shell

Execute shell commands with Fly

Install

npm install --save-dev fly-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

fly-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 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')
    .shell('cat $file')
    //=> fly-shell: console.log('this is src/a.js')
    //=> fly-shell: console.log('this is src/b.js')
    //=> fly-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 * () {
  yield this.source('src/*.js')
    .shell('cat $file', {glob: true})
    //=> fly-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 this.source(['src/*.js', 'src/*.css'])
    .shell({
      cmd: 'cat $glob', 
      glob: true
    })
    //=> fly-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 * () {
  yield this.source('src')
    .shell('ls -alh $file')
    .dist('dist');
}

License

MIT © Luke Edwards

Keywords

fly

FAQs

Package last updated on 31 Jan 2017

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