Comparing version 0.1.0 to 0.1.1
(function() { | ||
var FFI, fs, libc, uniqId, uniqIdK; | ||
var FFI, fs, libc, tmpDir, uniqId, uniqIdK; | ||
@@ -19,9 +19,26 @@ FFI = require("node-ffi"); | ||
tmpDir = function() { | ||
var dir, name, _i, _len, _ref; | ||
_ref = ['TMPDIR', 'TMP', 'TEMP']; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
name = _ref[_i]; | ||
if (process.env[name] != null) { | ||
dir = process.env[name]; | ||
if (dir.charAt(dir.length - 1) === '/') { | ||
return dir.substr(0, dir.length - 1); | ||
} | ||
return dir; | ||
} | ||
} | ||
return '/tmp'; | ||
}; | ||
module.exports = function(cmd) { | ||
var result, tmp; | ||
var dir, result, tmp; | ||
tmp = uniqId() + '.tmp'; | ||
cmd = "" + cmd + " > " + __dirname + "/" + tmp; | ||
dir = tmpDir(); | ||
cmd = "" + cmd + " > " + dir + "/" + tmp; | ||
libc.system(cmd); | ||
result = fs.readFileSync("" + __dirname + "/" + tmp); | ||
fs.unlinkSync("" + __dirname + "/" + tmp); | ||
result = fs.readFileSync("" + dir + "/" + tmp); | ||
fs.unlinkSync("" + dir + "/" + tmp); | ||
result = "" + result; | ||
@@ -28,0 +45,0 @@ if (result.charAt(result.length - 1) === "\n") { |
{ | ||
"name": "exec-sync", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Execute shell command synchronously. Use this for migration scripts, cli programs, but not for regular server code.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
4967
42
3