Skip to content

Commit 9e2719c

Browse files
committed
Fix lint errors and refactor types
1 parent efdfd38 commit 9e2719c

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

src/helpers/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const formatStdout = (stdout: string) =>
1+
export const formatStdout = (stdout: string): string =>
22
stdout
33
.replace(/.*\n/, '')
44
.replace(/- Removing|- Saving|- Retrieving project/, '')

src/helpers/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { exec as execCallback } from 'child_process'
33
import pLimit = require('p-limit')
44
const { access } = fs
55

6-
export const exists = (path: string) =>
6+
export const exists = (path: string): Promise<boolean> =>
77
access(path)
88
.then(_ => true)
99
.catch(_ => false)
1010

1111
export const exec = (cmd: string): Promise<string> =>
12-
new Promise((res, rej) =>
12+
new Promise((res, _rej) =>
1313
execCallback(cmd, (_, stdout, stderr) => res(stdout + stderr)),
1414
)
1515

src/helpers/parse.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import type { Argv } from '../types/types'
1+
import type { DeploymentEnv } from '../types/shared'
22

3-
export const parseArgv = (argv: typeof process.argv) => {
3+
export const parseArgv = (
4+
argv: typeof process.argv,
5+
): {
6+
deploymentEnv: DeploymentEnv
7+
varNameArr: string[] | null
8+
} => {
49
if (
510
argv[2] === 'production' ||
611
argv[2] === 'preview' ||
712
argv[2] === 'development'
813
) {
9-
const [deploymentEnv, ...varNameArr]: Argv = [argv[2], ...argv.slice(3)]
14+
const [deploymentEnv, ...varNameArr]: [DeploymentEnv, ...string[]] = [
15+
argv[2],
16+
...argv.slice(3),
17+
]
1018

1119
return { deploymentEnv, varNameArr: varNameArr.length ? varNameArr : null }
1220
} else {

src/helpers/print.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import { formatStdout } from './format'
22

3-
export const printStdout = (stdout: string) => console.log(formatStdout(stdout))
3+
export const printStdout = (stdout: string): void =>
4+
console.log(formatStdout(stdout))
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export type DeploymentEnv = 'production' | 'preview' | 'development'
2-
export type Argv = [DeploymentEnv, ...string[]]
32
export type EnvMap = Record<string, string>

src/utils/get-env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { exists } from '../helpers/helpers'
22
import { GetEnvVars } from 'env-cmd'
3-
import type { DeploymentEnv, EnvMap } from '../types/types'
3+
import type { DeploymentEnv, EnvMap } from '../types/shared'
44

55
export const getEnvMap = async (
66
deploymentEnv: DeploymentEnv,
77
varNameArr?: string[],
8-
) => {
8+
): Promise<EnvMap> => {
99
let envMap: EnvMap
1010

1111
if (await exists(`.env.${deploymentEnv}`)) {

src/utils/vercel-env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { exec, limit } from '../helpers/helpers'
22
import { printStdout } from '../helpers/print'
33
import { getEnvMap } from './get-env'
4-
import type { DeploymentEnv, EnvMap } from '../types/types'
4+
import type { DeploymentEnv, EnvMap } from '../types/shared'
55

66
const removeEnv = async (deploymentEnv: DeploymentEnv, envMap: EnvMap) => {
77
const stdoutArr: Promise<void>[] = []
@@ -38,7 +38,7 @@ const addEnv = async (deploymentEnv: DeploymentEnv, envMap: EnvMap) => {
3838
export const deployEnv = async (
3939
deploymentEnv: DeploymentEnv,
4040
varNameArr?: string[],
41-
) => {
41+
): Promise<void> => {
4242
const envMap = await getEnvMap(deploymentEnv, varNameArr)
4343

4444
await removeEnv(deploymentEnv, envMap)

0 commit comments

Comments
 (0)