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

@geek/spawn

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geek/spawn - npm Package Compare versions

Comparing version 0.0.1-beta.5 to 0.0.1-beta.6

7

package.json
{
"name": "@geek/spawn",
"version": "0.0.1-beta.5",
"version": "0.0.1-beta.6",
"description": "a cross-platform spawn replacement with promises",

@@ -37,3 +37,6 @@ "keywords": [],

},
"dependencies": {}
"dependencies": {
"chalk": "^1.1.3",
"debug": "^2.2.0"
}
}
'use strict';
var _ = require("lodash");
var child_process = require('child_process');
var path = require("path");
const _ = require("lodash");
const child_process = require('child_process');
const path = require("path");
const chalk = require("chalk");
const module_name = path.parse(module.id).name;
const SEPARATOR = process.platform === "win32" ? ";" : ":";
var env = Object.assign({}, process.env);
var SEPARATOR = process.platform === "win32" ? ";" : ":";
env.PATH = path.resolve(path.join(__dirname, "/node_modules/.bin")) + SEPARATOR + env.PATH;
// debug logger
var logger = (func_name) => {
var prefix = func_name ? `[${module_name}.${func_name}] ` : `[${module_name}`;
return _.wrap(require('debug')('geek-spawn'), (func, msg) => func(chalk.blue(`[${module_name}.execute] `) + msg));
}
let debug = logger();
exports.spawnSync = function(cmd, args, opts) {
let debug = logger('spawnSync');
opts = opts || {};

@@ -16,3 +25,3 @@ opts.stdio = 'inherit';

if (process.platform === 'win32') {
if(process.platform === 'win32') {
args = ['/c', cmd].concat(args);

@@ -26,12 +35,13 @@ cmd = process.env.comspec;

exports.spawn = function(cmd, args, opts) {
var successfulExitCodes = (opts && opts.successfulExitCodes) || [0];
let debug = logger('spawn');
return new Promise(function(resolve, reject) {
opts = opts || {};
opts.successfulExitCodes = opts.successfulExitCodes || [0];
opts.stdio = 'inherit';
opts.env = env;
_.defaults(opts, {
successfulExitCodes: [0],
stdio: 'inherit',
env: env
})
if (process.platform === 'win32') {
if(process.platform === 'win32') {
args = ['/c', cmd].concat(args);

@@ -41,2 +51,3 @@ cmd = process.env.comspec;

debug("Spawning in " + opts.cwd + ": " + cmd + " " + args.join(" "));
var child = child_process.spawn(cmd, args, opts);

@@ -46,6 +57,6 @@

if (!_.includes(opts.successfulExitCodes, code)) {
if(!_.includes(opts.successfulExitCodes, code)) {
var err = {
code: code,
message: "'" + cmd + " " + _.join(args," ") + "' failed with code " + code,
message: "'" + cmd + " " + _.join(args, " ") + "' failed with code " + code,
childProcess: child,

@@ -67,3 +78,3 @@ toString() {

child.on('error', (err) => {
child.on('error', err => {
reject(err);

@@ -70,0 +81,0 @@ });

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