mirror of
https://github.com/toddbluhm/env-cmd.git
synced 2025-12-08 18:23:33 +00:00
chore(package): update dependencies
This commit is contained in:
parent
7af4005431
commit
e66cfc10f1
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,17 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## 10.1.1 - Pending
|
||||
- **Upgrade**: Updated devDependencies `ts-standard`
|
||||
## 10.1.1 - In Development
|
||||
|
||||
- **Upgrade**: Upgraded dependency `commander` to `5.x`
|
||||
- **Upgrade**: Upgraded devDependencies `ts-standard`, `sinon`
|
||||
|
||||
## 10.1.0
|
||||
|
||||
- **Feature**: Added support for expanding vars using the `-x` flag.
|
||||
- **Feature**: Added support for expanding vars using the `-x` flag.
|
||||
Note: only supports `$var` syntax
|
||||
- **Feature**: Added support for `--silent` flag that ignores env-cmd errors and missing files and
|
||||
only terminates on caught signals
|
||||
- **Feature**: Added a new `--verbose` flag that prints additional debugging info to `console.info`
|
||||
- **Upgrade**: Updated dependency `commander` to `v4`
|
||||
- **Upgrade**: Updated devDependencies `sinon`, `nyc`, and `ts-standard`
|
||||
- **Upgrade**: Upgraded dependency `commander` to `4.x`
|
||||
- **Upgrade**: Upgraded devDependencies `sinon`, `nyc`, and `ts-standard`
|
||||
- **Fix**: Handle case where the termination signal is the termination code
|
||||
|
||||
## 10.0.1
|
||||
|
||||
2
dist/env-cmd.js
vendored
2
dist/env-cmd.js
vendored
@ -39,7 +39,7 @@ async function EnvCmd({ command, commandArgs, envFile, rc, options = {} }) {
|
||||
env = await get_env_vars_1.getEnvVars({ envFile, rc, verbose: options.verbose });
|
||||
}
|
||||
catch (e) {
|
||||
if (!(_a = options.silent, (_a !== null && _a !== void 0 ? _a : false))) {
|
||||
if (!((_a = options.silent) !== null && _a !== void 0 ? _a : false)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
4
dist/get-env-vars.js
vendored
4
dist/get-env-vars.js
vendored
@ -8,13 +8,13 @@ async function getEnvVars(options = {}) {
|
||||
options.envFile = options.envFile !== undefined ? options.envFile : {};
|
||||
// Check for rc file usage
|
||||
if (options.rc !== undefined) {
|
||||
return getRCFile({
|
||||
return await getRCFile({
|
||||
environments: options.rc.environments,
|
||||
filePath: options.rc.filePath,
|
||||
verbose: options.verbose
|
||||
});
|
||||
}
|
||||
return getEnvFile({
|
||||
return await getEnvFile({
|
||||
filePath: options.envFile.filePath,
|
||||
fallback: options.envFile.fallback,
|
||||
verbose: options.verbose
|
||||
|
||||
4
dist/parse-args.d.ts
vendored
4
dist/parse-args.d.ts
vendored
@ -1,7 +1,7 @@
|
||||
import { Command } from 'commander';
|
||||
import * as commander from 'commander';
|
||||
import { EnvCmdOptions } from './types';
|
||||
/**
|
||||
* Parses the arguments passed into the cli
|
||||
*/
|
||||
export declare function parseArgs(args: string[]): EnvCmdOptions;
|
||||
export declare function parseArgsUsingCommander(args: string[]): Command;
|
||||
export declare function parseArgsUsingCommander(args: string[]): commander.Command;
|
||||
|
||||
11
dist/parse-args.js
vendored
11
dist/parse-args.js
vendored
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const commander_1 = require("commander");
|
||||
const commander = require("commander");
|
||||
const utils_1 = require("./utils");
|
||||
// Use commonjs require to prevent a weird folder hierarchy in dist
|
||||
const packageJson = require('../package.json'); /* eslint-disable-line */
|
||||
@ -8,11 +8,13 @@ const packageJson = require('../package.json'); /* eslint-disable-line */
|
||||
* Parses the arguments passed into the cli
|
||||
*/
|
||||
function parseArgs(args) {
|
||||
// Get the command and command args
|
||||
// Run the initial arguments through commander in order to determine
|
||||
// which value in the args array is the `command` to execute
|
||||
let program = parseArgsUsingCommander(args);
|
||||
const command = program.args[0];
|
||||
// Grab all arguments after the `command` in the args array
|
||||
const commandArgs = args.splice(args.indexOf(command) + 1);
|
||||
// Reprocess the args with the command and command args removed
|
||||
// Reprocess the args with the command and command arguments removed
|
||||
program = parseArgsUsingCommander(args.slice(0, args.indexOf(command)));
|
||||
// Set values for provided options
|
||||
let noOverride = false;
|
||||
@ -70,7 +72,7 @@ function parseArgs(args) {
|
||||
}
|
||||
exports.parseArgs = parseArgs;
|
||||
function parseArgsUsingCommander(args) {
|
||||
const program = new commander_1.Command();
|
||||
const program = new commander.Command();
|
||||
return program
|
||||
.version(packageJson.version, '-v, --version')
|
||||
.usage('[options] <command> [...args]')
|
||||
@ -83,6 +85,7 @@ function parseArgsUsingCommander(args) {
|
||||
.option('--use-shell', 'Execute the command in a new shell with the given environment')
|
||||
.option('--verbose', 'Print helpful debugging information')
|
||||
.option('-x, --expand-envs', 'Replace $var in args and command with environment variables')
|
||||
.allowUnknownOption(true)
|
||||
.parse(['_', '_', ...args]);
|
||||
}
|
||||
exports.parseArgsUsingCommander = parseArgsUsingCommander;
|
||||
|
||||
12
dist/signal-termination.js
vendored
12
dist/signal-termination.js
vendored
@ -27,7 +27,7 @@ class TermSignals {
|
||||
// Use the signal code if it is an error code
|
||||
let correctSignal;
|
||||
if (typeof signal === 'number') {
|
||||
if (signal > ((code !== null && code !== void 0 ? code : 0))) {
|
||||
if (signal > (code !== null && code !== void 0 ? code : 0)) {
|
||||
code = signal;
|
||||
correctSignal = 'SIGINT';
|
||||
}
|
||||
@ -36,7 +36,7 @@ class TermSignals {
|
||||
correctSignal = signal;
|
||||
}
|
||||
// Kill the child process
|
||||
proc.kill((correctSignal !== null && correctSignal !== void 0 ? correctSignal : code));
|
||||
proc.kill(correctSignal !== null && correctSignal !== void 0 ? correctSignal : code);
|
||||
// Terminate the parent process
|
||||
this._terminateProcess(code, correctSignal);
|
||||
}
|
||||
@ -49,8 +49,8 @@ class TermSignals {
|
||||
this._removeProcessListeners();
|
||||
if (!this._exitCalled) {
|
||||
if (this.verbose) {
|
||||
console.info(`Child process exited with code: ${((code !== null && code !== void 0 ? code : '')).toString()} and signal:` +
|
||||
((signal !== null && signal !== void 0 ? signal : '')).toString() +
|
||||
console.info(`Child process exited with code: ${(code !== null && code !== void 0 ? code : '').toString()} and signal:` +
|
||||
(signal !== null && signal !== void 0 ? signal : '').toString() +
|
||||
'. Terminating parent process...');
|
||||
}
|
||||
// Mark shared state so we do not run into a signal/exit loop
|
||||
@ -58,13 +58,13 @@ class TermSignals {
|
||||
// Use the signal code if it is an error code
|
||||
let correctSignal;
|
||||
if (typeof signal === 'number') {
|
||||
if (signal > ((code !== null && code !== void 0 ? code : 0))) {
|
||||
if (signal > (code !== null && code !== void 0 ? code : 0)) {
|
||||
code = signal;
|
||||
correctSignal = 'SIGINT';
|
||||
}
|
||||
}
|
||||
else {
|
||||
correctSignal = (signal !== null && signal !== void 0 ? signal : undefined);
|
||||
correctSignal = signal !== null && signal !== void 0 ? signal : undefined;
|
||||
}
|
||||
// Terminate the parent process
|
||||
this._terminateProcess(code, correctSignal);
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/toddbluhm/env-cmd#readme",
|
||||
"dependencies": {
|
||||
"commander": "^4.0.0",
|
||||
"commander": "^5.0.0",
|
||||
"cross-spawn": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -63,9 +63,9 @@
|
||||
"husky": "^4.0.0",
|
||||
"mocha": "^7.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"sinon": "^8.0.0",
|
||||
"sinon": "^9.0.0",
|
||||
"ts-node": "^8.0.0",
|
||||
"ts-standard": "^5.0.0",
|
||||
"ts-standard": "^7.0.0",
|
||||
"typescript": "^3.7.0"
|
||||
},
|
||||
"nyc": {
|
||||
|
||||
@ -17,7 +17,7 @@ export async function CLI (args: string[]): Promise<{ [key: string]: any }> {
|
||||
|
||||
// Run EnvCmd
|
||||
try {
|
||||
return await exports.EnvCmd(parsedArgs)
|
||||
return await (exports.EnvCmd(parsedArgs) as Promise<{ [key: string]: any }>)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return process.exit(1)
|
||||
|
||||
@ -9,13 +9,13 @@ export async function getEnvVars (options: GetEnvVarOptions = {}): Promise<{ [ke
|
||||
options.envFile = options.envFile !== undefined ? options.envFile : {}
|
||||
// Check for rc file usage
|
||||
if (options.rc !== undefined) {
|
||||
return getRCFile({
|
||||
return await getRCFile({
|
||||
environments: options.rc.environments,
|
||||
filePath: options.rc.filePath,
|
||||
verbose: options.verbose
|
||||
})
|
||||
}
|
||||
return getEnvFile({
|
||||
return await getEnvFile({
|
||||
filePath: options.envFile.filePath,
|
||||
fallback: options.envFile.fallback,
|
||||
verbose: options.verbose
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Command } from 'commander'
|
||||
import * as commander from 'commander'
|
||||
import { EnvCmdOptions } from './types'
|
||||
import { parseArgList } from './utils'
|
||||
|
||||
@ -9,12 +9,14 @@ const packageJson = require('../package.json') /* eslint-disable-line */
|
||||
* Parses the arguments passed into the cli
|
||||
*/
|
||||
export function parseArgs (args: string[]): EnvCmdOptions {
|
||||
// Get the command and command args
|
||||
// Run the initial arguments through commander in order to determine
|
||||
// which value in the args array is the `command` to execute
|
||||
let program = parseArgsUsingCommander(args)
|
||||
const command = program.args[0]
|
||||
// Grab all arguments after the `command` in the args array
|
||||
const commandArgs = args.splice(args.indexOf(command) + 1)
|
||||
|
||||
// Reprocess the args with the command and command args removed
|
||||
// Reprocess the args with the command and command arguments removed
|
||||
program = parseArgsUsingCommander(args.slice(0, args.indexOf(command)))
|
||||
|
||||
// Set values for provided options
|
||||
@ -75,8 +77,8 @@ export function parseArgs (args: string[]): EnvCmdOptions {
|
||||
return options
|
||||
}
|
||||
|
||||
export function parseArgsUsingCommander (args: string[]): Command {
|
||||
const program = new Command()
|
||||
export function parseArgsUsingCommander (args: string[]): commander.Command {
|
||||
const program = new commander.Command()
|
||||
return program
|
||||
.version(packageJson.version, '-v, --version')
|
||||
.usage('[options] <command> [...args]')
|
||||
@ -89,5 +91,6 @@ export function parseArgsUsingCommander (args: string[]): Command {
|
||||
.option('--use-shell', 'Execute the command in a new shell with the given environment')
|
||||
.option('--verbose', 'Print helpful debugging information')
|
||||
.option('-x, --expand-envs', 'Replace $var in args and command with environment variables')
|
||||
.allowUnknownOption(true)
|
||||
.parse(['_', '_', ...args])
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import { parseArgs } from '../src/parse-args'
|
||||
|
||||
describe('parseArgs', (): void => {
|
||||
const command = 'command'
|
||||
const commandArgs = ['cmda1', 'cmda2', '--cmda3', '-4', 'cmda4']
|
||||
const commandArgs = ['cmda1', 'cmda2', '--cmda3', '-4', 'cmda4', '--fallback']
|
||||
const environments = ['development', 'production']
|
||||
const rcFilePath = './.env-cmdrc'
|
||||
const envFilePath = './.env'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user