All Projects → moxystudio → Node Cross Spawn

moxystudio / Node Cross Spawn

Licence: mit
A cross platform solution to node's spawn and spawnSync

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Cross Spawn

Mitype
Typing speed test in terminal
Stars: ✭ 241 (-71%)
Mutual labels:  cmd, cross-platform
Mojoc
A cross-platform, open-source, pure C game engine for mobile game.
Stars: ✭ 799 (-3.85%)
Mutual labels:  cross-platform
Cf Tool
📊 Codeforces CLI (Submit, Parse, Test, etc.). Support Contests, Gym, Groups, acmsguru, Windows, macOS, Linux, 7 MB
Stars: ✭ 723 (-13%)
Mutual labels:  cross-platform
Essential Ui Kit For Xamarin.forms
Free and beautiful XAML template pages for Xamarin.Forms apps.
Stars: ✭ 780 (-6.14%)
Mutual labels:  cross-platform
Splat
Makes things cross-platform
Stars: ✭ 753 (-9.39%)
Mutual labels:  cross-platform
Git Interactive Rebase Tool
Native cross-platform full feature terminal-based sequence editor for git interactive rebase.
Stars: ✭ 786 (-5.42%)
Mutual labels:  cross-platform
Flutter thrio
flutter_thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.
Stars: ✭ 717 (-13.72%)
Mutual labels:  cross-platform
Nodegui
A library for building cross-platform native desktop applications with Node.js and CSS 🚀. React NodeGui : https://react.nodegui.org and Vue NodeGui: https://vue.nodegui.org
Stars: ✭ 7,324 (+781.35%)
Mutual labels:  cross-platform
Liteide
LiteIDE is a simple, open source, cross-platform Go IDE.
Stars: ✭ 6,657 (+701.08%)
Mutual labels:  cross-platform
Fkill Cli
Fabulously kill processes. Cross-platform.
Stars: ✭ 6,418 (+672.32%)
Mutual labels:  cross-platform
Vidcutter
Been busy guys, will be reviewing and integrating pull requests shortly. Thanks to all contributors! LATEST RELEASE: 6.0.0 - flatpak @ https://flathub.org/apps/details/com.ozmartians.VidCutter - snap @ https://snapcraft.io/vidcutter - see https://github.com/ozmartian/vidcutter/releases for more details...
Stars: ✭ 775 (-6.74%)
Mutual labels:  cross-platform
Reaktive
Kotlin multi-platform implementation of Reactive Extensions
Stars: ✭ 760 (-8.54%)
Mutual labels:  cross-platform
Flyingcarpet
Encrypted file transfer over ad hoc WiFi. No network infrastructure required, just two laptops in close range. Linux, Mac, and Windows.
Stars: ✭ 788 (-5.17%)
Mutual labels:  cross-platform
Tmux Mem Cpu Load
CPU, RAM, and load monitor for use with tmux
Stars: ✭ 746 (-10.23%)
Mutual labels:  cross-platform
Azurite
A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
Stars: ✭ 810 (-2.53%)
Mutual labels:  cross-platform
Qimgv
Qt5 image viewer with optional video support
Stars: ✭ 714 (-14.08%)
Mutual labels:  cross-platform
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (-6.74%)
Mutual labels:  cross-platform
Everest
A beautiful, cross-platform REST client.
Stars: ✭ 785 (-5.54%)
Mutual labels:  cross-platform
Sfml
Simple and Fast Multimedia Library
Stars: ✭ 7,316 (+780.39%)
Mutual labels:  cross-platform
Fluidsynth
Software synthesizer based on the SoundFont 2 specifications
Stars: ✭ 811 (-2.41%)
Mutual labels:  cross-platform

cross-spawn

NPM version Downloads Build Status Build status Coverage Status Dependency status Dev Dependency status

A cross platform solution to node's spawn and spawnSync.

Installation

Node.js version 8 and up: $ npm install cross-spawn

Node.js version 7 and under: $ npm install [email protected]

Why

Node has issues when using spawn on Windows:

  • It ignores PATHEXT
  • It does not support shebangs
  • Has problems running commands with spaces
  • Has problems running commands with posix relative paths (e.g.: ./my-folder/my-executable)
  • Has an issue with command shims (files in node_modules/.bin/), where arguments with quotes and parenthesis would result in invalid syntax error
  • No options.shell support on node <v4.8

All these issues are handled correctly by cross-spawn. There are some known modules, such as win-spawn, that try to solve this but they are either broken or provide faulty escaping of shell arguments.

Usage

Exactly the same way as node's spawn or spawnSync, so it's a drop in replacement.

const spawn = require('cross-spawn');

// Spawn NPM asynchronously
const child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });

// Spawn NPM synchronously
const result = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });

Caveats

Using options.shell as an alternative to cross-spawn

Starting from node v4.8, spawn has a shell option that allows you run commands from within a shell. This new option solves the PATHEXT issue but:

  • It's not supported in node <v4.8
  • You must manually escape the command and arguments which is very error prone, specially when passing user input
  • There are a lot of other unresolved issues from the Why section that you must take into account

If you are using the shell option to spawn a command in a cross platform way, consider using cross-spawn instead. You have been warned.

options.shell support

While cross-spawn adds support for options.shell in node <v4.8, all of its enhancements are disabled.

This mimics the Node.js behavior. More specifically, the command and its arguments will not be automatically escaped nor shebang support will be offered. This is by design because if you are using options.shell you are probably targeting a specific platform anyway and you don't want things to get into your way.

Shebangs support

While cross-spawn handles shebangs on Windows, its support is limited. More specifically, it just supports #!/usr/bin/env <program> where <program> must not contain any arguments.
If you would like to have the shebang support improved, feel free to contribute via a pull-request.

Remember to always test your code on Windows!

Tests

$ npm test
$ npm test -- --watch during development

License

Released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].