Skip to content

Commit 8912681

Browse files
committed
refactor helpers
1 parent b0a3089 commit 8912681

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/helpers/exec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { exec as execCallback } from 'child_process'
2+
3+
export const exec = (cmd: string): Promise<string> => new Promise( (res,rej) =>
4+
execCallback( cmd, (_,stdout,stderr) => res(stdout + stderr) )
5+
)

src/helpers/format.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const formatStdout = (stdout: string) => (
2+
stdout
3+
.replace( /.*\n/, '' )
4+
.replace( /- Removing|- Saving|- Retrieving project/, '' )
5+
.trim()
6+
)

src/helpers/helpers.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/helpers/print.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { formatStdout } from './format'
2+
3+
export const printStdoutList = async (stdoutList: Promise<string>[]) => {
4+
for await (const stdout of stdoutList) {
5+
console.log( formatStdout(stdout) )
6+
}
7+
}

0 commit comments

Comments
 (0)