Skip to content

Commit dcabfc9

Browse files
committed
print stdout in order of promise resolution
1 parent 8e985b5 commit dcabfc9

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/helpers/print.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
import { formatStdout } from './format'
22

3-
export const printStdoutList = async (stdoutList: Promise<string>[]) => {
4-
for await (const stdout of stdoutList) {
5-
console.log( formatStdout(stdout) )
6-
}
7-
}
3+
export const printStdout = (stdout: string) => console.log( formatStdout(stdout) )

src/utils/vercel-env.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import { exec } from '../helpers/helpers'
2-
import { printStdoutList } from '../helpers/print'
2+
import { printStdout } from '../helpers/print'
33
import { getEnvVarMap } from './get-env'
44
import type { DeploymentEnv, EnvVarMap } from '../types/types'
55

66
const removeEnv = async (deploymentEnv: DeploymentEnv, envVarMap: EnvVarMap) => {
7-
const stdoutList: Promise<string>[] = []
7+
const stdoutList: Promise<void>[] = []
88
for (const varName in envVarMap) {
99
stdoutList.push(
10-
exec( `vercel env rm ${varName} ${deploymentEnv} -y` )
10+
exec( `vercel env rm ${varName} ${deploymentEnv} -y` ).then(printStdout)
1111
)
1212
}
1313

14-
await printStdoutList(stdoutList)
14+
await Promise.all(stdoutList)
1515
}
1616

1717
const addEnv = async (deploymentEnv: DeploymentEnv, envVarMap: EnvVarMap) => {
18-
const stdoutList: Promise<string>[] = []
18+
const stdoutList: Promise<void>[] = []
1919
for (const varName in envVarMap) {
2020
const varValue = envVarMap[varName]
2121
stdoutList.push(
22-
exec( `echo -n ${varValue} | vercel env add ${varName} ${deploymentEnv}` )
22+
exec( `echo -n ${varValue} | vercel env add ${varName} ${deploymentEnv}` ).then(printStdout)
2323
)
2424
}
2525

26-
await printStdoutList(stdoutList)
26+
await Promise.all(stdoutList)
2727
}
2828

2929
export const deployEnv = async (deploymentEnv: DeploymentEnv, varNameList?: string[]) => {

0 commit comments

Comments
 (0)