xnr
Version:
Easily, quickly and reliably run a Node.js script from the CLI.
26 lines (25 loc) • 1.3 kB
TypeScript
import { type SucraseOptions } from "./utils";
export { type Output } from "./calcOutput";
export { transform } from "./transform";
export type RunConfig = {
filePath: string;
args?: string[];
nodeArgs?: string[];
getSucraseOptions?: (absFilePath: string) => SucraseOptions;
outputDirectory?: string | undefined;
onWriteStdout?: (message: string) => void;
onWriteStderr?: (message: string) => void;
};
/**
* Runs a file with auto-transpilation of it and its dependencies, as required.
*
* @param {string|RunConfig} filePathOrConfig - The path of the file to run or a configuration object.
* @param {string} [filePath] - (or [config.filePath]) The path of the file to run.
* @param {string[]} [config.args] - Arguments to pass to the script.
* @param {string[]} [config.nodeArgs] - Node.js arguments to pass when running the script.
* @param {string} [config.outputDirectory] - Directory for storing output files.
* @param {Function} [config.onWriteStdout] - Function to handle standard output.
* @param {Function} [config.onWriteStderr] - Function to handle standard error output.
* @returns {Promise<number>} A promise that resolves with the exit code of the process.
*/
export declare const run: (filePathOrConfig: string | RunConfig) => Promise<number>;