create-dotenv
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -8,3 +8,3 @@ # Changelog | ||
## 2.0.5 (2022-08-29) | ||
## 2.0.6 (2022-08-29) | ||
@@ -11,0 +11,0 @@ ### Added |
859
index.js
@@ -5,268 +5,8 @@ #!/usr/bin/env node | ||
var require$$0 = require('fs'); | ||
var require$$0$2 = require('child_process'); | ||
var require$$0$1 = require('path'); | ||
var require$$2 = require('path-key'); | ||
var require$$1 = require('shebang-command'); | ||
var fs = require('fs'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); | ||
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2); | ||
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1); | ||
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); | ||
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); | ||
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
var minimist = function (args, opts) { | ||
if (!opts) opts = {}; | ||
var flags = { bools : {}, strings : {}, unknownFn: null }; | ||
if (typeof opts['unknown'] === 'function') { | ||
flags.unknownFn = opts['unknown']; | ||
} | ||
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { | ||
flags.allBools = true; | ||
} else { | ||
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) { | ||
flags.bools[key] = true; | ||
}); | ||
} | ||
var aliases = {}; | ||
Object.keys(opts.alias || {}).forEach(function (key) { | ||
aliases[key] = [].concat(opts.alias[key]); | ||
aliases[key].forEach(function (x) { | ||
aliases[x] = [key].concat(aliases[key].filter(function (y) { | ||
return x !== y; | ||
})); | ||
}); | ||
}); | ||
[].concat(opts.string).filter(Boolean).forEach(function (key) { | ||
flags.strings[key] = true; | ||
if (aliases[key]) { | ||
flags.strings[aliases[key]] = true; | ||
} | ||
}); | ||
var defaults = opts['default'] || {}; | ||
var argv = { _ : [] }; | ||
Object.keys(flags.bools).forEach(function (key) { | ||
setArg(key, defaults[key] === undefined ? false : defaults[key]); | ||
}); | ||
var notFlags = []; | ||
if (args.indexOf('--') !== -1) { | ||
notFlags = args.slice(args.indexOf('--')+1); | ||
args = args.slice(0, args.indexOf('--')); | ||
} | ||
function argDefined(key, arg) { | ||
return (flags.allBools && /^--[^=]+$/.test(arg)) || | ||
flags.strings[key] || flags.bools[key] || aliases[key]; | ||
} | ||
function setArg (key, val, arg) { | ||
if (arg && flags.unknownFn && !argDefined(key, arg)) { | ||
if (flags.unknownFn(arg) === false) return; | ||
} | ||
var value = !flags.strings[key] && isNumber(val) | ||
? Number(val) : val | ||
; | ||
setKey(argv, key.split('.'), value); | ||
(aliases[key] || []).forEach(function (x) { | ||
setKey(argv, x.split('.'), value); | ||
}); | ||
} | ||
function setKey (obj, keys, value) { | ||
var o = obj; | ||
for (var i = 0; i < keys.length-1; i++) { | ||
var key = keys[i]; | ||
if (isConstructorOrProto(o, key)) return; | ||
if (o[key] === undefined) o[key] = {}; | ||
if (o[key] === Object.prototype || o[key] === Number.prototype | ||
|| o[key] === String.prototype) o[key] = {}; | ||
if (o[key] === Array.prototype) o[key] = []; | ||
o = o[key]; | ||
} | ||
var key = keys[keys.length - 1]; | ||
if (isConstructorOrProto(o, key)) return; | ||
if (o === Object.prototype || o === Number.prototype | ||
|| o === String.prototype) o = {}; | ||
if (o === Array.prototype) o = []; | ||
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { | ||
o[key] = value; | ||
} | ||
else if (Array.isArray(o[key])) { | ||
o[key].push(value); | ||
} | ||
else { | ||
o[key] = [ o[key], value ]; | ||
} | ||
} | ||
function aliasIsBoolean(key) { | ||
return aliases[key].some(function (x) { | ||
return flags.bools[x]; | ||
}); | ||
} | ||
for (var i = 0; i < args.length; i++) { | ||
var arg = args[i]; | ||
if (/^--.+=/.test(arg)) { | ||
// Using [\s\S] instead of . because js doesn't support the | ||
// 'dotall' regex modifier. See: | ||
// http://stackoverflow.com/a/1068308/13216 | ||
var m = arg.match(/^--([^=]+)=([\s\S]*)$/); | ||
var key = m[1]; | ||
var value = m[2]; | ||
if (flags.bools[key]) { | ||
value = value !== 'false'; | ||
} | ||
setArg(key, value, arg); | ||
} | ||
else if (/^--no-.+/.test(arg)) { | ||
var key = arg.match(/^--no-(.+)/)[1]; | ||
setArg(key, false, arg); | ||
} | ||
else if (/^--.+/.test(arg)) { | ||
var key = arg.match(/^--(.+)/)[1]; | ||
var next = args[i + 1]; | ||
if (next !== undefined && !/^-/.test(next) | ||
&& !flags.bools[key] | ||
&& !flags.allBools | ||
&& (aliases[key] ? !aliasIsBoolean(key) : true)) { | ||
setArg(key, next, arg); | ||
i++; | ||
} | ||
else if (/^(true|false)$/.test(next)) { | ||
setArg(key, next === 'true', arg); | ||
i++; | ||
} | ||
else { | ||
setArg(key, flags.strings[key] ? '' : true, arg); | ||
} | ||
} | ||
else if (/^-[^-]+/.test(arg)) { | ||
var letters = arg.slice(1,-1).split(''); | ||
var broken = false; | ||
for (var j = 0; j < letters.length; j++) { | ||
var next = arg.slice(j+2); | ||
if (next === '-') { | ||
setArg(letters[j], next, arg); | ||
continue; | ||
} | ||
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { | ||
setArg(letters[j], next.split('=')[1], arg); | ||
broken = true; | ||
break; | ||
} | ||
if (/[A-Za-z]/.test(letters[j]) | ||
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { | ||
setArg(letters[j], next, arg); | ||
broken = true; | ||
break; | ||
} | ||
if (letters[j+1] && letters[j+1].match(/\W/)) { | ||
setArg(letters[j], arg.slice(j+2), arg); | ||
broken = true; | ||
break; | ||
} | ||
else { | ||
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); | ||
} | ||
} | ||
var key = arg.slice(-1)[0]; | ||
if (!broken && key !== '-') { | ||
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) | ||
&& !flags.bools[key] | ||
&& (aliases[key] ? !aliasIsBoolean(key) : true)) { | ||
setArg(key, args[i+1], arg); | ||
i++; | ||
} | ||
else if (args[i+1] && /^(true|false)$/.test(args[i+1])) { | ||
setArg(key, args[i+1] === 'true', arg); | ||
i++; | ||
} | ||
else { | ||
setArg(key, flags.strings[key] ? '' : true, arg); | ||
} | ||
} | ||
} | ||
else { | ||
if (!flags.unknownFn || flags.unknownFn(arg) !== false) { | ||
argv._.push( | ||
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) | ||
); | ||
} | ||
if (opts.stopEarly) { | ||
argv._.push.apply(argv._, args.slice(i + 1)); | ||
break; | ||
} | ||
} | ||
} | ||
Object.keys(defaults).forEach(function (key) { | ||
if (!hasKey(argv, key.split('.'))) { | ||
setKey(argv, key.split('.'), defaults[key]); | ||
(aliases[key] || []).forEach(function (x) { | ||
setKey(argv, x.split('.'), defaults[key]); | ||
}); | ||
} | ||
}); | ||
if (opts['--']) { | ||
argv['--'] = new Array(); | ||
notFlags.forEach(function(key) { | ||
argv['--'].push(key); | ||
}); | ||
} | ||
else { | ||
notFlags.forEach(function(key) { | ||
argv._.push(key); | ||
}); | ||
} | ||
return argv; | ||
}; | ||
function hasKey (obj, keys) { | ||
var o = obj; | ||
keys.slice(0,-1).forEach(function (key) { | ||
o = (o[key] || {}); | ||
}); | ||
var key = keys[keys.length - 1]; | ||
return key in o; | ||
} | ||
function isNumber (x) { | ||
if (typeof x === 'number') return true; | ||
if (/^0x[0-9a-f]+$/i.test(x)) return true; | ||
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); | ||
} | ||
function isConstructorOrProto (obj, key) { | ||
return key === 'constructor' && typeof obj[key] === 'function' || key === '__proto__'; | ||
} | ||
function trimPrefix(s, prefix) { | ||
@@ -402,3 +142,3 @@ if (s.startsWith(prefix)) { | ||
try { | ||
const file = require$$0__default["default"].readFileSync(filename, "utf-8"); | ||
const file = fs__default["default"].readFileSync(filename, "utf-8"); | ||
return this.parse(file); | ||
@@ -414,593 +154,6 @@ } catch (error) { | ||
var crossSpawn = {exports: {}}; | ||
const minimist = require("minimist"); | ||
var windows; | ||
var hasRequiredWindows; | ||
const spawn = require("cross-spawn"); | ||
function requireWindows () { | ||
if (hasRequiredWindows) return windows; | ||
hasRequiredWindows = 1; | ||
windows = isexe; | ||
isexe.sync = sync; | ||
var fs = require$$0__default["default"]; | ||
function checkPathExt (path, options) { | ||
var pathext = options.pathExt !== undefined ? | ||
options.pathExt : process.env.PATHEXT; | ||
if (!pathext) { | ||
return true | ||
} | ||
pathext = pathext.split(';'); | ||
if (pathext.indexOf('') !== -1) { | ||
return true | ||
} | ||
for (var i = 0; i < pathext.length; i++) { | ||
var p = pathext[i].toLowerCase(); | ||
if (p && path.substr(-p.length).toLowerCase() === p) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
function checkStat (stat, path, options) { | ||
if (!stat.isSymbolicLink() && !stat.isFile()) { | ||
return false | ||
} | ||
return checkPathExt(path, options) | ||
} | ||
function isexe (path, options, cb) { | ||
fs.stat(path, function (er, stat) { | ||
cb(er, er ? false : checkStat(stat, path, options)); | ||
}); | ||
} | ||
function sync (path, options) { | ||
return checkStat(fs.statSync(path), path, options) | ||
} | ||
return windows; | ||
} | ||
var mode; | ||
var hasRequiredMode; | ||
function requireMode () { | ||
if (hasRequiredMode) return mode; | ||
hasRequiredMode = 1; | ||
mode = isexe; | ||
isexe.sync = sync; | ||
var fs = require$$0__default["default"]; | ||
function isexe (path, options, cb) { | ||
fs.stat(path, function (er, stat) { | ||
cb(er, er ? false : checkStat(stat, options)); | ||
}); | ||
} | ||
function sync (path, options) { | ||
return checkStat(fs.statSync(path), options) | ||
} | ||
function checkStat (stat, options) { | ||
return stat.isFile() && checkMode(stat, options) | ||
} | ||
function checkMode (stat, options) { | ||
var mod = stat.mode; | ||
var uid = stat.uid; | ||
var gid = stat.gid; | ||
var myUid = options.uid !== undefined ? | ||
options.uid : process.getuid && process.getuid(); | ||
var myGid = options.gid !== undefined ? | ||
options.gid : process.getgid && process.getgid(); | ||
var u = parseInt('100', 8); | ||
var g = parseInt('010', 8); | ||
var o = parseInt('001', 8); | ||
var ug = u | g; | ||
var ret = (mod & o) || | ||
(mod & g) && gid === myGid || | ||
(mod & u) && uid === myUid || | ||
(mod & ug) && myUid === 0; | ||
return ret | ||
} | ||
return mode; | ||
} | ||
var core; | ||
if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) { | ||
core = requireWindows(); | ||
} else { | ||
core = requireMode(); | ||
} | ||
var isexe_1 = isexe$1; | ||
isexe$1.sync = sync; | ||
function isexe$1 (path, options, cb) { | ||
if (typeof options === 'function') { | ||
cb = options; | ||
options = {}; | ||
} | ||
if (!cb) { | ||
if (typeof Promise !== 'function') { | ||
throw new TypeError('callback not provided') | ||
} | ||
return new Promise(function (resolve, reject) { | ||
isexe$1(path, options || {}, function (er, is) { | ||
if (er) { | ||
reject(er); | ||
} else { | ||
resolve(is); | ||
} | ||
}); | ||
}) | ||
} | ||
core(path, options || {}, function (er, is) { | ||
// ignore EACCES because that just means we aren't allowed to run it | ||
if (er) { | ||
if (er.code === 'EACCES' || options && options.ignoreErrors) { | ||
er = null; | ||
is = false; | ||
} | ||
} | ||
cb(er, is); | ||
}); | ||
} | ||
function sync (path, options) { | ||
// my kingdom for a filtered catch | ||
try { | ||
return core.sync(path, options || {}) | ||
} catch (er) { | ||
if (options && options.ignoreErrors || er.code === 'EACCES') { | ||
return false | ||
} else { | ||
throw er | ||
} | ||
} | ||
} | ||
const isWindows = process.platform === 'win32' || | ||
process.env.OSTYPE === 'cygwin' || | ||
process.env.OSTYPE === 'msys'; | ||
const path$2 = require$$0__default$1["default"]; | ||
const COLON = isWindows ? ';' : ':'; | ||
const isexe = isexe_1; | ||
const getNotFoundError = (cmd) => | ||
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' }); | ||
const getPathInfo = (cmd, opt) => { | ||
const colon = opt.colon || COLON; | ||
// If it has a slash, then we don't bother searching the pathenv. | ||
// just check the file itself, and that's it. | ||
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [''] | ||
: ( | ||
[ | ||
// windows always checks the cwd first | ||
...(isWindows ? [process.cwd()] : []), | ||
...(opt.path || process.env.PATH || | ||
/* istanbul ignore next: very unusual */ '').split(colon), | ||
] | ||
); | ||
const pathExtExe = isWindows | ||
? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM' | ||
: ''; | ||
const pathExt = isWindows ? pathExtExe.split(colon) : ['']; | ||
if (isWindows) { | ||
if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') | ||
pathExt.unshift(''); | ||
} | ||
return { | ||
pathEnv, | ||
pathExt, | ||
pathExtExe, | ||
} | ||
}; | ||
const which$1 = (cmd, opt, cb) => { | ||
if (typeof opt === 'function') { | ||
cb = opt; | ||
opt = {}; | ||
} | ||
if (!opt) | ||
opt = {}; | ||
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt); | ||
const found = []; | ||
const step = i => new Promise((resolve, reject) => { | ||
if (i === pathEnv.length) | ||
return opt.all && found.length ? resolve(found) | ||
: reject(getNotFoundError(cmd)) | ||
const ppRaw = pathEnv[i]; | ||
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; | ||
const pCmd = path$2.join(pathPart, cmd); | ||
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd | ||
: pCmd; | ||
resolve(subStep(p, i, 0)); | ||
}); | ||
const subStep = (p, i, ii) => new Promise((resolve, reject) => { | ||
if (ii === pathExt.length) | ||
return resolve(step(i + 1)) | ||
const ext = pathExt[ii]; | ||
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => { | ||
if (!er && is) { | ||
if (opt.all) | ||
found.push(p + ext); | ||
else | ||
return resolve(p + ext) | ||
} | ||
return resolve(subStep(p, i, ii + 1)) | ||
}); | ||
}); | ||
return cb ? step(0).then(res => cb(null, res), cb) : step(0) | ||
}; | ||
const whichSync = (cmd, opt) => { | ||
opt = opt || {}; | ||
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt); | ||
const found = []; | ||
for (let i = 0; i < pathEnv.length; i ++) { | ||
const ppRaw = pathEnv[i]; | ||
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; | ||
const pCmd = path$2.join(pathPart, cmd); | ||
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd | ||
: pCmd; | ||
for (let j = 0; j < pathExt.length; j ++) { | ||
const cur = p + pathExt[j]; | ||
try { | ||
const is = isexe.sync(cur, { pathExt: pathExtExe }); | ||
if (is) { | ||
if (opt.all) | ||
found.push(cur); | ||
else | ||
return cur | ||
} | ||
} catch (ex) {} | ||
} | ||
} | ||
if (opt.all && found.length) | ||
return found | ||
if (opt.nothrow) | ||
return null | ||
throw getNotFoundError(cmd) | ||
}; | ||
var which_1 = which$1; | ||
which$1.sync = whichSync; | ||
const path$1 = require$$0__default$1["default"]; | ||
const which = which_1; | ||
const getPathKey = require$$2__default["default"]; | ||
function resolveCommandAttempt(parsed, withoutPathExt) { | ||
const env = parsed.options.env || process.env; | ||
const cwd = process.cwd(); | ||
const hasCustomCwd = parsed.options.cwd != null; | ||
// Worker threads do not have process.chdir() | ||
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled; | ||
// If a custom `cwd` was specified, we need to change the process cwd | ||
// because `which` will do stat calls but does not support a custom cwd | ||
if (shouldSwitchCwd) { | ||
try { | ||
process.chdir(parsed.options.cwd); | ||
} catch (err) { | ||
/* Empty */ | ||
} | ||
} | ||
let resolved; | ||
try { | ||
resolved = which.sync(parsed.command, { | ||
path: env[getPathKey({ env })], | ||
pathExt: withoutPathExt ? path$1.delimiter : undefined, | ||
}); | ||
} catch (e) { | ||
/* Empty */ | ||
} finally { | ||
if (shouldSwitchCwd) { | ||
process.chdir(cwd); | ||
} | ||
} | ||
// If we successfully resolved, ensure that an absolute path is returned | ||
// Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it | ||
if (resolved) { | ||
resolved = path$1.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved); | ||
} | ||
return resolved; | ||
} | ||
function resolveCommand$1(parsed) { | ||
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true); | ||
} | ||
var resolveCommand_1 = resolveCommand$1; | ||
var _escape = {}; | ||
// See http://www.robvanderwoude.com/escapechars.php | ||
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g; | ||
function escapeCommand(arg) { | ||
// Escape meta chars | ||
arg = arg.replace(metaCharsRegExp, '^$1'); | ||
return arg; | ||
} | ||
function escapeArgument(arg, doubleEscapeMetaChars) { | ||
// Convert to string | ||
arg = `${arg}`; | ||
// Algorithm below is based on https://qntm.org/cmd | ||
// Sequence of backslashes followed by a double quote: | ||
// double up all the backslashes and escape the double quote | ||
arg = arg.replace(/(\\*)"/g, '$1$1\\"'); | ||
// Sequence of backslashes followed by the end of the string | ||
// (which will become a double quote later): | ||
// double up all the backslashes | ||
arg = arg.replace(/(\\*)$/, '$1$1'); | ||
// All other backslashes occur literally | ||
// Quote the whole thing: | ||
arg = `"${arg}"`; | ||
// Escape meta chars | ||
arg = arg.replace(metaCharsRegExp, '^$1'); | ||
// Double escape meta chars if necessary | ||
if (doubleEscapeMetaChars) { | ||
arg = arg.replace(metaCharsRegExp, '^$1'); | ||
} | ||
return arg; | ||
} | ||
_escape.command = escapeCommand; | ||
_escape.argument = escapeArgument; | ||
const fs = require$$0__default["default"]; | ||
const shebangCommand = require$$1__default["default"]; | ||
function readShebang$1(command) { | ||
// Read the first 150 bytes from the file | ||
const size = 150; | ||
const buffer = Buffer.alloc(size); | ||
let fd; | ||
try { | ||
fd = fs.openSync(command, 'r'); | ||
fs.readSync(fd, buffer, 0, size, 0); | ||
fs.closeSync(fd); | ||
} catch (e) { /* Empty */ } | ||
// Attempt to extract shebang (null is returned if not a shebang) | ||
return shebangCommand(buffer.toString()); | ||
} | ||
var readShebang_1 = readShebang$1; | ||
const path = require$$0__default$1["default"]; | ||
const resolveCommand = resolveCommand_1; | ||
const escape = _escape; | ||
const readShebang = readShebang_1; | ||
const isWin$1 = process.platform === 'win32'; | ||
const isExecutableRegExp = /\.(?:com|exe)$/i; | ||
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; | ||
function detectShebang(parsed) { | ||
parsed.file = resolveCommand(parsed); | ||
const shebang = parsed.file && readShebang(parsed.file); | ||
if (shebang) { | ||
parsed.args.unshift(parsed.file); | ||
parsed.command = shebang; | ||
return resolveCommand(parsed); | ||
} | ||
return parsed.file; | ||
} | ||
function parseNonShell(parsed) { | ||
if (!isWin$1) { | ||
return parsed; | ||
} | ||
// Detect & add support for shebangs | ||
const commandFile = detectShebang(parsed); | ||
// We don't need a shell if the command filename is an executable | ||
const needsShell = !isExecutableRegExp.test(commandFile); | ||
// If a shell is required, use cmd.exe and take care of escaping everything correctly | ||
// Note that `forceShell` is an hidden option used only in tests | ||
if (parsed.options.forceShell || needsShell) { | ||
// Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/` | ||
// The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument | ||
// Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called, | ||
// we need to double escape them | ||
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile); | ||
// Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar) | ||
// This is necessary otherwise it will always fail with ENOENT in those cases | ||
parsed.command = path.normalize(parsed.command); | ||
// Escape command & arguments | ||
parsed.command = escape.command(parsed.command); | ||
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars)); | ||
const shellCommand = [parsed.command].concat(parsed.args).join(' '); | ||
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`]; | ||
parsed.command = process.env.comspec || 'cmd.exe'; | ||
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped | ||
} | ||
return parsed; | ||
} | ||
function parse$1(command, args, options) { | ||
// Normalize arguments, similar to nodejs | ||
if (args && !Array.isArray(args)) { | ||
options = args; | ||
args = null; | ||
} | ||
args = args ? args.slice(0) : []; // Clone array to avoid changing the original | ||
options = Object.assign({}, options); // Clone object to avoid changing the original | ||
// Build our parsed object | ||
const parsed = { | ||
command, | ||
args, | ||
options, | ||
file: undefined, | ||
original: { | ||
command, | ||
args, | ||
}, | ||
}; | ||
// Delegate further parsing to shell or non-shell | ||
return options.shell ? parsed : parseNonShell(parsed); | ||
} | ||
var parse_1 = parse$1; | ||
const isWin = process.platform === 'win32'; | ||
function notFoundError(original, syscall) { | ||
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), { | ||
code: 'ENOENT', | ||
errno: 'ENOENT', | ||
syscall: `${syscall} ${original.command}`, | ||
path: original.command, | ||
spawnargs: original.args, | ||
}); | ||
} | ||
function hookChildProcess(cp, parsed) { | ||
if (!isWin) { | ||
return; | ||
} | ||
const originalEmit = cp.emit; | ||
cp.emit = function (name, arg1) { | ||
// If emitting "exit" event and exit code is 1, we need to check if | ||
// the command exists and emit an "error" instead | ||
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16 | ||
if (name === 'exit') { | ||
const err = verifyENOENT(arg1, parsed); | ||
if (err) { | ||
return originalEmit.call(cp, 'error', err); | ||
} | ||
} | ||
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params | ||
}; | ||
} | ||
function verifyENOENT(status, parsed) { | ||
if (isWin && status === 1 && !parsed.file) { | ||
return notFoundError(parsed.original, 'spawn'); | ||
} | ||
return null; | ||
} | ||
function verifyENOENTSync(status, parsed) { | ||
if (isWin && status === 1 && !parsed.file) { | ||
return notFoundError(parsed.original, 'spawnSync'); | ||
} | ||
return null; | ||
} | ||
var enoent$1 = { | ||
hookChildProcess, | ||
verifyENOENT, | ||
verifyENOENTSync, | ||
notFoundError, | ||
}; | ||
const cp = require$$0__default$2["default"]; | ||
const parse = parse_1; | ||
const enoent = enoent$1; | ||
function spawn(command, args, options) { | ||
// Parse the arguments | ||
const parsed = parse(command, args, options); | ||
// Spawn the child process | ||
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options); | ||
// Hook into child process "exit" event to emit an error if the command | ||
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 | ||
enoent.hookChildProcess(spawned, parsed); | ||
return spawned; | ||
} | ||
function spawnSync(command, args, options) { | ||
// Parse the arguments | ||
const parsed = parse(command, args, options); | ||
// Spawn the child process | ||
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options); | ||
// Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 | ||
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); | ||
return result; | ||
} | ||
crossSpawn.exports = spawn; | ||
crossSpawn.exports.spawn = spawn; | ||
crossSpawn.exports.sync = spawnSync; | ||
crossSpawn.exports._parse = parse; | ||
crossSpawn.exports._enoent = enoent; | ||
function printHelp() { | ||
@@ -1077,3 +230,3 @@ console.log(["Usage: dotenv-cli [--help] [--debug] [-e <path>] [-v <name>=<value>] [-p <variable name>] [-- command]", " --help print help", " --debug output the files that would be processed but don't actually parse them or run the `command`", " -e <path> parses the file <path> as a `.env` file and adds the variables to the environment", " -e <path> multiple -e flags are allowed", " -v <name>=<value> put variable <name> into environment using value <value>", " -v <name>=<value> multiple -v flags are allowed", " -p <variable> print value of <variable> to the console. If you specify this, you do not have to specify a `command`", " command `command` is the actual command you want to run. Best practice is to precede this command with ` -- `. Everything after `--` is considered to be your command. So any flags will not be parsed by this tool but be passed to your command. If you do not do it, this tool will strip those flags"].join("\n")); | ||
crossSpawn.exports(command, argv._.slice(1), { | ||
spawn(command, argv._.slice(1), { | ||
stdio: "inherit" | ||
@@ -1080,0 +233,0 @@ }).on("exit", function (exitCode, signal) { |
{ | ||
"name": "create-dotenv", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Loads environment variables from .env file", | ||
@@ -40,7 +40,3 @@ "publishConfig": { | ||
"dependencies": { | ||
"@jsdotenv/core": "^2.0.5", | ||
"chalk": "4.1.2", | ||
"commander": "^9.4.0", | ||
"envinfo": "^7.8.1", | ||
"leven": "^4.0.0", | ||
"@jsdotenv/core": "^2.0.6", | ||
"minimist": "^1.2.6" | ||
@@ -47,0 +43,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
2
6
1
9823
181
- Removedchalk@4.1.2
- Removedcommander@^9.4.0
- Removedenvinfo@^7.8.1
- Removedleven@^4.0.0
- Removedansi-styles@4.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedcommander@9.5.0(transitive)
- Removedenvinfo@7.14.0(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedleven@4.0.0(transitive)
- Removedsupports-color@7.2.0(transitive)
Updated@jsdotenv/core@^2.0.6