Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shellkit

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shellkit

write shell scripts in javascript using promises

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
Maintainers
1
Weekly downloads
 
Created
Source

Shellkit

asynchronous unix shell commands for es6 and beyond

Example

import 'shellkit/global'

script(function* () {
  yield mkdirp('build/js')

  yield touch('build/js/bundle.js')

  for (let file of yield ls('src')) {
    if (file.slice(-3) === '.js') {
      yield cat(`src/${file}`).appendTo('build/js/bundle.js')
    }
  }

  if ((yield exec('gzip -k build/js/bundle.js').code) !== 0) {
    echo('Failed to gzip build/js/bundle.js')
    exit(1)
  }
})

Install

npm install shellkit

Global vs local

Import shellkit/global if you want it to pollute your global namespace.

import 'shellkit/global'

script(/* ... */)

Otherwise you can do this:

import * as sh from 'shellkit'

sh.script(/* ... */)

API

  • spawn(String: command, Array: args [, Object: options]) => Promise
  • exec`interpolated ${command}` => Promise
  • parallel(...Promises) => Promise
  • echo(...Mixed)
  • exit(Number: code)
  • ls(String: directory) => Promise => Array[String]
  • mv(String: source, String: dest) => Promise
  • writeFile(String: path, String|Buffer: data [, Object: options]) => Promise
  • appendFile(String: path, String|Buffer: data [, Object: options]) => Promise
  • exists(String: path) => Promise => Boolean
  • rm(String: path) => Promise
  • rmrf(String: path) => Promise
  • rmdir(String: path) => Promise
  • chown(String: path, Octal: uid, Octal: gid) => Promise
  • chmod(String: path, Octal: uid, Octal: gid) => Promise
  • stat(String: path) => Promise
  • lstat(String: path) => Promise
  • mkdir(String: path [, Octal: mode=0777]) => Promise
  • mkdirp(String: path [, Octal: mode=0777]) => Promise
  • uptime() => Number: uptime in seconds
  • loadavg() => Array[Number]
  • open(String: path, String: flags [, Octal: mode]) => Promise => Number: fd
  • close(Number: fd) => Promise
  • touch(String: path) => Promise
  • isFile(String: path) => Promise => Boolean
  • isDirectory(String: path) => Promise => Boolean
  • isBlockDevice(String: path) => Promise => Boolean
  • isCharacterDevice(String: path) => Promise => Boolean
  • isSymbolicLink(String: path) => Promise => Boolean
  • isFIFO(String: path) => Promise => Boolean
  • isSocket(String: path) => Promise => Boolean
  • cat(...Strings: paths) => Stream & Promise using as a promise will resolve with the complete file contents, but you can also pipe
  • cd(String: path)
  • cwd() => String: path
  • env Object: same as process.env
  • cp(String: source, String: destination [, Object: opts]) => Promise
  • tmpfile([String: extension [, String: basedir]]) => Promise => String: path
  • tmpdir([String: parentDirectory]) => Promise => String: path
  • sleep(Number: seconds) => Promise resolves when X seconds have passed
  • stream(Stream: original) => Stream & Promise using as a promise will resolve with the complete output, but you can also pipe
  • script(Async Function | Generator: fn) runs the given function and handles any errors

License

MIT

FAQs

Package last updated on 14 Oct 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc