mirror of
https://github.com/toddbluhm/env-cmd.git
synced 2025-12-08 18:23:33 +00:00
Switch to dist folder and output typescript declaration files
This commit is contained in:
parent
3534069ece
commit
cd3018f25b
@ -1,2 +1,2 @@
|
|||||||
#! /usr/bin/env node
|
#! /usr/bin/env node
|
||||||
require('../lib').CLI(process.argv.slice(2))
|
require('../dist').CLI(process.argv.slice(2))
|
||||||
|
|||||||
21
dist/env-cmd.d.ts
vendored
Normal file
21
dist/env-cmd.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { EnvCmdOptions } from './types';
|
||||||
|
/**
|
||||||
|
* Executes env - cmd using command line arguments
|
||||||
|
* @export
|
||||||
|
* @param {string[]} args Command line argument to pass in ['-f', './.env']
|
||||||
|
* @returns {Promise<{ [key: string]: any }>}
|
||||||
|
*/
|
||||||
|
export declare function CLI(args: string[]): Promise<{
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
|
/**
|
||||||
|
* The main env-cmd program. This will spawn a new process and run the given command using
|
||||||
|
* various environment file solutions.
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {EnvCmdOptions} { command, commandArgs, envFile, rc, options }
|
||||||
|
* @returns {Promise<{ [key: string]: any }>} Returns an object containing [environment variable name]: value
|
||||||
|
*/
|
||||||
|
export declare function EnvCmd({ command, commandArgs, envFile, rc, options }: EnvCmdOptions): Promise<{
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
0
lib/env-cmd.js → dist/env-cmd.js
vendored
0
lib/env-cmd.js → dist/env-cmd.js
vendored
16
dist/get-env-vars.d.ts
vendored
Normal file
16
dist/get-env-vars.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { GetEnvVarOptions } from './types';
|
||||||
|
export declare function getEnvVars(options?: GetEnvVarOptions): Promise<{
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
|
export declare function getEnvFile({ filePath, fallback }: {
|
||||||
|
filePath?: string;
|
||||||
|
fallback?: boolean;
|
||||||
|
}): Promise<{
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
|
export declare function getRCFile({ environments, filePath }: {
|
||||||
|
environments: string[];
|
||||||
|
filePath?: string;
|
||||||
|
}): Promise<{
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
0
lib/help.js → dist/help.js
vendored
0
lib/help.js → dist/help.js
vendored
4
dist/index.d.ts
vendored
Normal file
4
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { getEnvVars } from './get-env-vars';
|
||||||
|
export * from './types';
|
||||||
|
export * from './env-cmd';
|
||||||
|
export declare const GetEnvVars: typeof getEnvVars;
|
||||||
0
lib/index.js → dist/index.js
vendored
0
lib/index.js → dist/index.js
vendored
5
dist/parse-args.d.ts
vendored
Normal file
5
dist/parse-args.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { EnvCmdOptions } from './types';
|
||||||
|
/**
|
||||||
|
* Parses the arguments passed into the cli
|
||||||
|
*/
|
||||||
|
export declare function parseArgs(args: string[]): EnvCmdOptions;
|
||||||
0
lib/parse-args.js → dist/parse-args.js
vendored
0
lib/parse-args.js → dist/parse-args.js
vendored
26
dist/parse-env-file.d.ts
vendored
Normal file
26
dist/parse-env-file.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Gets the environment vars from an env file
|
||||||
|
*/
|
||||||
|
export declare function getEnvFileVars(envFilePath: string): Promise<{
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
|
/**
|
||||||
|
* Parse out all env vars from a given env file string and return an object
|
||||||
|
*/
|
||||||
|
export declare function parseEnvString(envFileString: string): {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Parse out all env vars from an env file string
|
||||||
|
*/
|
||||||
|
export declare function parseEnvVars(envString: string): {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Strips out comments from env file string
|
||||||
|
*/
|
||||||
|
export declare function stripComments(envString: string): string;
|
||||||
|
/**
|
||||||
|
* Strips out newlines from env file string
|
||||||
|
*/
|
||||||
|
export declare function stripEmptyLines(envString: string): string;
|
||||||
15
dist/parse-rc-file.d.ts
vendored
Normal file
15
dist/parse-rc-file.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Gets the env vars from the rc file and rc environments
|
||||||
|
*/
|
||||||
|
export declare function getRCFileVars({ environments, filePath }: {
|
||||||
|
environments: string[];
|
||||||
|
filePath: string;
|
||||||
|
}): Promise<{
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
|
/**
|
||||||
|
* Reads and parses the .rc file
|
||||||
|
*/
|
||||||
|
export declare function parseRCFile(fileData: string): {
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
23
dist/signal-termination.d.ts
vendored
Normal file
23
dist/signal-termination.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
|
import { ChildProcess } from 'child_process';
|
||||||
|
export declare class TermSignals {
|
||||||
|
private terminateSpawnedProcessFuncHandlers;
|
||||||
|
_exitCalled: boolean;
|
||||||
|
handleTermSignals(proc: ChildProcess): void;
|
||||||
|
/**
|
||||||
|
* Enables catching of unhandled exceptions
|
||||||
|
*/
|
||||||
|
handleUncaughtExceptions(): void;
|
||||||
|
/**
|
||||||
|
* Terminate parent process helper
|
||||||
|
*/
|
||||||
|
_terminateProcess(code?: number, signal?: string): void;
|
||||||
|
/**
|
||||||
|
* Exit event listener clean up helper
|
||||||
|
*/
|
||||||
|
_removeProcessListeners(): void;
|
||||||
|
/**
|
||||||
|
* General exception handler
|
||||||
|
*/
|
||||||
|
_uncaughtExceptionHandler(e: Error): void;
|
||||||
|
}
|
||||||
2
dist/spawn.d.ts
vendored
Normal file
2
dist/spawn.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import * as spawn from 'cross-spawn';
|
||||||
|
export { spawn };
|
||||||
0
lib/spawn.js → dist/spawn.js
vendored
0
lib/spawn.js → dist/spawn.js
vendored
18
dist/types.d.ts
vendored
Normal file
18
dist/types.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export interface GetEnvVarOptions {
|
||||||
|
envFile?: {
|
||||||
|
filePath?: string;
|
||||||
|
fallback?: boolean;
|
||||||
|
};
|
||||||
|
rc?: {
|
||||||
|
environments: string[];
|
||||||
|
filePath?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export interface EnvCmdOptions extends GetEnvVarOptions {
|
||||||
|
command: string;
|
||||||
|
commandArgs: string[];
|
||||||
|
options?: {
|
||||||
|
noOverride?: boolean;
|
||||||
|
useShell?: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
0
lib/types.js → dist/types.js
vendored
0
lib/types.js → dist/types.js
vendored
12
dist/utils.d.ts
vendored
Normal file
12
dist/utils.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* A simple function for resolving the path the user entered
|
||||||
|
*/
|
||||||
|
export declare function resolveEnvFilePath(userPath: string): string;
|
||||||
|
/**
|
||||||
|
* A simple function that parses a comma separated string into an array of strings
|
||||||
|
*/
|
||||||
|
export declare function parseArgList(list: string): string[];
|
||||||
|
/**
|
||||||
|
* A simple function to test if the value is a promise
|
||||||
|
*/
|
||||||
|
export declare function isPromise(value: any | PromiseLike<Object>): boolean;
|
||||||
0
lib/utils.js → dist/utils.js
vendored
0
lib/utils.js → dist/utils.js
vendored
@ -2,7 +2,8 @@
|
|||||||
"name": "env-cmd",
|
"name": "env-cmd",
|
||||||
"version": "9.0.0",
|
"version": "9.0.0",
|
||||||
"description": "Executes a command using the envs in the provided env file",
|
"description": "Executes a command using the envs in the provided env file",
|
||||||
"main": "lib/index.js",
|
"main": "dist/index.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.0.0"
|
"node": ">=8.0.0"
|
||||||
},
|
},
|
||||||
@ -10,11 +11,11 @@
|
|||||||
"env-cmd": "bin/env-cmd.js"
|
"env-cmd": "bin/env-cmd.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha -r ts-node/register ./**/*.ts",
|
"test": "mocha -r ts-node/register ./test/**/*.ts",
|
||||||
"test-cover": "nyc --reporter=lcov --reporter=text npm test",
|
"test-cover": "nyc --reporter=lcov --reporter=text npm test",
|
||||||
"test-lint": "eslint ./**/*.ts",
|
"test-lint": "eslint ./src/**/*.ts ./test/**/*.ts",
|
||||||
"coveralls": "coveralls < coverage/lcov.info",
|
"coveralls": "coveralls < coverage/lcov.info",
|
||||||
"lint": "eslint --fix ./**/*.ts",
|
"lint": "eslint --fix ./src/**/*.ts ./test/**/*.ts",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./lib",
|
"outDir": "./dist",
|
||||||
"target": "es2015",
|
"target": "es2015",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
"declaration": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2015",
|
"es2015",
|
||||||
"es2016",
|
"es2016",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user