@gasket/utils
Advanced tools
Comparing version 6.20.0 to 6.20.2
@@ -0,1 +1,3 @@ | ||
import type { GasketConfig } from '@gasket/engine'; | ||
/** | ||
@@ -39,1 +41,73 @@ * Wrapper class for executing commands for a given package manager | ||
} | ||
export function tryRequire(path: string): object|null; | ||
/** | ||
* Normalize the config by applying any overrides for environments, commands, | ||
* or local-only config file. | ||
* | ||
* @param config - Target config to be normalized | ||
* @param context - Context for applying overrides | ||
* @param context.env - Name of environment | ||
* @param [context.commandId] - Name of command | ||
* @param [context.root] - Project root; required if using localeFile | ||
* @param [context.localFile] - Optional file to load relative to gasket root | ||
* @returns config | ||
*/ | ||
export function applyConfigOverrides(config: GasketConfig, { env, commandId, root, localFile }: { | ||
env: string; | ||
commandId?: string; | ||
root?: string; | ||
localFile?: string; | ||
}): GasketConfig; | ||
/** | ||
* Normalize the config by applying any environment or local overrides | ||
* | ||
* @param gasketConfig - Gasket config | ||
* @param config - Target config to be normalized | ||
* @param [localFile] - Optional file to load relative to gasket root | ||
* @returns config | ||
* @deprecated use applyConfigOverrides | ||
*/ | ||
declare function applyEnvironmentOverrides(gasketConfig: GasketConfig, config: GasketConfig, localFile?: string): object; | ||
/** | ||
* Promise friendly wrapper to running a shell command (eg: git, npm, ls) | ||
* which passes back any { stdout, stderr } to the error thrown. | ||
* | ||
* Options can be passed to the underlying spawn. An additional `signal` option | ||
* can be passed to use AbortController, allowing processes to be killed when | ||
* no longer needed. | ||
* | ||
* @example | ||
* const { runShellCommand } = require('@gasket/utils'); | ||
* | ||
* async function helloWorld() { | ||
* await runShellCommand('echo', ['hello world']); | ||
* } | ||
* | ||
* @example | ||
* // With timeout using AbortController | ||
* | ||
* const { runShellCommand } = require('@gasket/utils'); | ||
* const AbortController = require('abort-controller'); | ||
* | ||
* async function helloWorld() { | ||
* const controller = new AbortController(); | ||
* // abort the process after 60 seconds | ||
* const id = setTimeout(() => controller.abort(), 60000); | ||
* await runShellCommand('long-process', ['something'], { signal: controller.signal }); | ||
* clearTimeout(id); | ||
* } | ||
* | ||
* @param cmd - Binary that is run | ||
* @param [argv] - Arguments passed to npm binary through spawn. | ||
* @param [options] options passed to npm binary through spawn | ||
* @param [options.signal] AbortControl signal allowing process to be canceled | ||
* @param [debug] When present pipes std{out,err} to process.* | ||
* @returns results | ||
*/ | ||
export function runShellCommand(cmd: string, argv?: string[], options?: { | ||
signal?: object; | ||
}, debug?: boolean): Promise<{ stdout: string }>; |
@@ -33,5 +33,5 @@ const concat = require('concat-stream'); | ||
* | ||
* @param {string} cmd binary that is run | ||
* @param {array} argv args passed to npm binary through spawn. | ||
* @param {object} options options passed to npm binary through spawn | ||
* @param {string} cmd Binary that is run | ||
* @param {string[]} [argv] Arguments passed to npm binary through spawn. | ||
* @param {object} [options] Options passed to npm binary through spawn | ||
* @param {object} [options.signal] AbortControl signal allowing process to be canceled | ||
@@ -38,0 +38,0 @@ * @param {boolean} [debug] When present pipes std{out,err} to process.* |
{ | ||
"name": "@gasket/utils", | ||
"version": "6.20.0", | ||
"version": "6.20.2", | ||
"description": "Reusable utilities for Gasket internals", | ||
@@ -47,2 +47,3 @@ "main": "lib", | ||
"devDependencies": { | ||
"@gasket/engine": "^6.20.2", | ||
"@godaddy/dmd": "^1.0.0", | ||
@@ -77,3 +78,3 @@ "abort-controller": "^3.0.0", | ||
], | ||
"gitHead": "3ec9b59670630b95ef54aa7048c01f2b9e2af52f" | ||
"gitHead": "0c34d84b6dd3010db139e90bbbda19b879a9396c" | ||
} |
26214
426
15