myst-cli-utils
Advanced tools
Comparing version 2.0.10 to 2.0.11
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import type { ExecOptions } from 'child_process'; | ||
@@ -6,3 +5,3 @@ import child_process from 'child_process'; | ||
export declare const exec: (arg1: string, arg2: { | ||
cwd?: string | undefined; | ||
cwd?: string; | ||
} | undefined) => Promise<string>; | ||
@@ -9,0 +8,0 @@ type Options = ExecOptions & { |
@@ -1,3 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import fs from 'node:fs'; | ||
@@ -4,0 +2,0 @@ import type { ISession } from './types.js'; |
@@ -9,2 +9,10 @@ import type { Command } from 'commander'; | ||
getSession: (logger: Logger, opts?: SessionOpts) => S; | ||
}, runOptions?: { | ||
/** | ||
* Wait for all promises to finish, even if the main command is complete. | ||
* | ||
* For example, when starting a watch process. | ||
* For build commands, this should be `false`, the default, to ensure a speedy exit from the CLI. | ||
*/ | ||
keepAlive?: boolean | ((...args: any[]) => boolean); | ||
}): (...args: any[]) => Promise<void>; | ||
@@ -11,0 +19,0 @@ export declare function tic(): (f?: string) => string; |
@@ -9,3 +9,3 @@ import prettyHrtime from 'pretty-hrtime'; | ||
} | ||
export function clirun(func, cli) { | ||
export function clirun(func, cli, runOptions) { | ||
return async (...args) => { | ||
@@ -25,2 +25,9 @@ const opts = cli.program.opts(); | ||
} | ||
if (typeof (runOptions === null || runOptions === void 0 ? void 0 : runOptions.keepAlive) === 'function') { | ||
if (!runOptions.keepAlive(...args)) | ||
process.exit(0); | ||
} | ||
else if (!(runOptions === null || runOptions === void 0 ? void 0 : runOptions.keepAlive)) { | ||
process.exit(0); | ||
} | ||
}; | ||
@@ -27,0 +34,0 @@ } |
{ | ||
"name": "myst-cli-utils", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21866
425