better-npm-run
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -0,0 +0,0 @@ #!/usr/bin/env node |
@@ -1,34 +0,36 @@ | ||
var child_exec = require('child_process').exec; | ||
var spawn = require('child_process').spawn; | ||
var dotenv = require('./dot-env'); | ||
var objectAssign = require('object-assign'); | ||
module.exports = function exec(script) { | ||
var command_line = script.command; | ||
// Grab the command section of the entered command | ||
var command = script.command.split(' ')[0]; | ||
// Anything else is options | ||
var options = script.command.split(' ').slice(1); | ||
Object.keys(script.env).forEach(function (key) { | ||
var value = script.env[key]; | ||
var argv = process.argv.splice(3); | ||
if(process.platform === 'win32') { | ||
command_line = 'set ' + key + '=' + script.env[key] + '&& ' + command_line; | ||
} else { | ||
command_line = key + '=' + script.env[key] + ' ' + command_line; | ||
} | ||
}); | ||
options = options.concat(argv); | ||
console.log('to be executed:' + command_line); | ||
var command = child_exec(command_line, function (error, stdout, stderr) { | ||
if (error) { | ||
process.exit(error.code || 1); | ||
} | ||
}); | ||
script.env = script.env || {}; | ||
var env = objectAssign(process.env, script.env, dotenv); | ||
console.log('to be executed:', command, options.join(' ')); | ||
var command = spawn(command, options, {env: env}); | ||
command.stdout.on('data', function(data) { | ||
process.stdout.write(data); | ||
process.stdout.write(data); | ||
}); | ||
command.stderr.on('data', function(data) { | ||
process.stderr.write(data); | ||
process.stderr.write(data); | ||
}); | ||
command.on('error', function(err) { | ||
process.stderr.write(err); | ||
process.exit(err.code || 1); | ||
process.stderr.write(err); | ||
process.exit(err.code || 1); | ||
}); | ||
} |
{ | ||
"name": "better-npm-run", | ||
"description": "Better NPM scripts runner", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "MIT", | ||
@@ -20,4 +20,16 @@ "author": "Benjamin Orozco <benoror@gmail.com>", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node index.js test --test" | ||
}, | ||
"dependencies": { | ||
"endofline": "0.0.3", | ||
"object-assign": "^4.0.1" | ||
}, | ||
"betterScripts": { | ||
"test": { | ||
"command": "node test.js", | ||
"env": { | ||
"FOO": "bar" | ||
} | ||
} | ||
} | ||
} |
@@ -73,1 +73,8 @@ [![NPM](https://nodei.co/npm/better-npm-run.png)](https://npmjs.org/package/better-npm-run) | ||
``` | ||
Also if you have .env file in your project root it will be loaded on every command | ||
``` | ||
NODE_PATH=./:./lib | ||
PORT=5000 | ||
``` |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
5836
8
82
2
79
2
3
+ Addedendofline@0.0.3
+ Addedobject-assign@^4.0.1
+ Addedendofline@0.0.3(transitive)
+ Addedobject-assign@4.1.1(transitive)