@tableau/taco-toolkit
Version:
Tableau Connector Toolkit
48 lines (47 loc) • 1.72 kB
TypeScript
/// <reference types="node" />
import { SpawnSyncOptions } from 'child_process';
import Spinner from './spinner';
export interface ExecutionState {
spinner: Spinner;
verbose: boolean;
}
/**
* If the input path is a relative path, it resolves the path from
* current working directory.
*
* @returns an absolute path
*/
export declare function resolvePath(rootPath: string): string;
/**
* The function is designated to valid if a path from user input exists.
* Note: this function only displays messages in console.
* It does not log any info into file.
*
* @param filePath a relative path will be resolved relative to the current working directory
* @param errorMessage error message to display before exit
*/
export declare function exitIfNonExistPath(filePath: string, errorMessage: string): void;
export declare function exitIfPathExists(filePath: string, errorMessage: string): void;
export declare function exitIfAnyMissingPath(paths: string[], errorMessage: string): void;
interface ExecutionError {
status: number | null;
stderr: string;
stdout: string;
error?: Error;
}
/**
* Invoking a global command with child_process.spawnSync
*/
export declare function executeCmd(cmd: string, params?: readonly string[], options?: SpawnSyncOptions): Result<string, ExecutionError>;
interface SuccessResult<D> {
state: 'success';
data?: D;
}
interface ErrorResult<E> {
state: 'error';
error: E;
}
export type Result<D, E> = SuccessResult<D> | ErrorResult<E>;
export declare function isSuccessResult<D>(result: Result<D, unknown>): result is SuccessResult<D>;
export declare function isErrorResult<E>(result: Result<unknown, E>): result is ErrorResult<E>;
export {};