denoify
Version:
For NPM module authors that would like to support Deno but do not want to write and maintain a port.
17 lines (14 loc) • 443 B
text/typescript
import * as st from "scripting-tools";
export function execFactory(params: { isDryRun: boolean }) {
const { isDryRun } = params;
const exec: (cmd: string) => Promise<void> = !isDryRun
? async cmd => {
console.log(`$ ${cmd}`);
await st.exec(cmd);
}
: cmd => {
console.log(`(dry)$ ${cmd}`);
return Promise.resolve();
};
return { exec };
}