Commit 2ec0f03
src/core.ts
@@ -29,7 +29,6 @@ import {
parseDuration,
psTree,
quote,
- substitute,
} from './util.js'
export type Shell = (
@@ -119,6 +118,13 @@ export const $ = new Proxy<Shell & Options>(
}
)
+function substitute(arg: ProcessPromise | any) {
+ if (arg?.stdout) {
+ return arg.stdout.replace(/\n$/, '')
+ }
+ return `${arg}`
+}
+
type Resolve = (out: ProcessOutput) => void
type IO = StdioPipe | StdioNull
src/goods.ts
@@ -16,8 +16,8 @@ import * as globbyModule from 'globby'
import minimist from 'minimist'
import nodeFetch, { RequestInfo, RequestInit } from 'node-fetch'
import { createInterface } from 'node:readline'
-import { $ } from './core.js'
-import { Duration, isString, parseDuration, stringify } from './util.js'
+import { $, ProcessOutput } from './core.js'
+import { Duration, isString, parseDuration } from './util.js'
export { default as chalk } from 'chalk'
export { default as fs } from 'fs-extra'
@@ -69,6 +69,13 @@ export function echo(pieces: TemplateStringsArray, ...args: any[]) {
console.log(msg)
}
+function stringify(arg: ProcessOutput | any) {
+ if (arg instanceof ProcessOutput) {
+ return arg.toString().replace(/\n$/, '')
+ }
+ return `${arg}`
+}
+
export async function question(
query?: string,
options?: { choices: string[] }
src/util.ts
@@ -15,7 +15,6 @@
import chalk from 'chalk'
import { promisify } from 'node:util'
import psTreeModule from 'ps-tree'
-import { ProcessOutput, ProcessPromise } from './core.js'
export const psTree = promisify(psTreeModule)
@@ -48,20 +47,6 @@ export function quote(arg: string) {
)
}
-export function substitute(arg: ProcessPromise | any) {
- if (arg?.stdout) {
- return arg.stdout.replace(/\n$/, '')
- }
- return `${arg}`
-}
-
-export function stringify(arg: ProcessOutput | any) {
- if (arg instanceof ProcessOutput) {
- return arg.toString().replace(/\n$/, '')
- }
- return `${arg}`
-}
-
export function exitCodeInfo(exitCode: number | null): string | undefined {
return {
2: 'Misuse of shell builtins',