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

shelljs.exec

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shelljs.exec

Replacement for shelljs' slow exec method - 20x faster

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

shelljs.exec

Build Status Coverage Status dependencies Status npm npm node

Replacement for shelljs' slow exec method - 20x faster


Introduction

shelljs is FAST but its exec method is SLOW, use this module instead of shelljs' exec method for speeds 20x faster

shelljs.exec is a zero-dependency module

It takes 2 arguments, the command to execute and an options object


Usage

On success:

var exec = require('shelljs.exec')
var cmdObj = exec('echo hello', {silent: true})

expect(cmdObj).to.eql({
  error: null,
  stdout: 'hello\n',
  stderr: '',
  code: 0,
  ok: true
})

On failure:

var exec = require('shelljs.exec')
var cmdObj = exec('blip blop', {silent: true})

expect(cmdObj.error).to.be.an('error')
expect(cmdObj.error.message).to.match(/not found|not recognized/)

expect(cmdObj.stdout).to.equal('')
expect(cmdObj.stderr).to.match(/not found|not recognized/)
expect(cmdObj.code).to.be.above(0)
expect(cmdObj.ok).to.be.false

Options object

  • silent: Do not echo any output to console. Defaults to false.

  • and any option available to Node.js' child_process.execSync


Benchmarks

Benchmark test result logs are HERE

Generally speaking, on Linux shelljs.exec is 20 times faster and on Windows 5 times faster.

These tables show average execution times based on 1000 test runs:

Linux (Travis CI) Node v6

commandshelljs.exec (this module)shelljs.exec (from shelljs)shelljs supported command
echo hello4.16ms103.45ms24.9x slower0.17ms (shelljs.echo)24.4x faster
which git75.43ms169.85ms2.3x slower0.90ms (shelljs.which)83.5x faster
cat file1 file23.97ms105.03ms26.5x slower0.59ms (shelljs.cat)6.7x faster
printf hello3.17ms97.84ms30.8x slowerN/A
whoami4.42ms110.14ms24.9x slowerN/A
git rev-parse --is-inside-work-tree4.88ms100.61ms20.6x slowerN/A

Windows (GIT bash) Node v6.10.0

commandshelljs.exec (this module)shelljs.exec (from shelljs)shelljs supported command
echo hello15.56ms188.52ms12.1x slower0.43ms (shelljs.echo)35.9x faster
which git164.37ms332.20ms2.0x slower1.19ms (shelljs.which)138.6x faster
cat file1 file240.97ms217.73ms5.3x slower0.77ms (shelljs.cat)53.3x faster
printf hello43.55ms235.87ms5.4x slowerN/A
whoami45.26ms247.77ms5.5x slowerN/A
git rev-parse --is-inside-work-tree43.41ms231.35ms5.3x slowerN/A

Author says

But as the days of Noah were, so also will the coming of the Son of Man be. 38 For as in the days before the flood, they were eating and drinking, marrying and giving in marriage, until the day that Noah entered the ark, 39 and did not know until the flood came and took them all away, so also will the coming of the Son of Man be.

Matthew 24:37-39

Keywords

FAQs

Package last updated on 17 Sep 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

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