Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve lint issue in src/parse-rc-file.ts #386

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/get-env-vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ export async function getRCFile (
}
if (e.name === 'ParseError') {
if (verbose === true) {
console.info(e.message);
console.info(e.message)
}
throw new Error(e.message);
throw new Error(e.message)
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/parse-rc-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export async function getRCFileVars (
parsedData = JSON.parse(file)
}
} catch (e) {
const parseError = new Error(`Failed to parse .rc file at path: ${absolutePath}.\n${e.message}`)
const errorMessage = e instanceof Error ? e.message : 'Unknown error'
const parseError = new Error(
`Failed to parse .rc file at path: ${absolutePath}.\n${errorMessage}`
)
parseError.name = 'ParseError'
throw parseError
}
Expand Down
14 changes: 7 additions & 7 deletions test/parse-args.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ describe('parseArgs', (): void => {
it('should parse environment value', (): void => {
const res = parseArgs(['-e', environments[0], command])
assert.exists(res.rc)
assert.sameOrderedMembers(res.rc!.environments, [environments[0]])
assert.sameOrderedMembers(res.rc.environments, [environments[0]])
})

it('should parse multiple environment values', (): void => {
const res = parseArgs(['-e', environments.join(','), command])
assert.exists(res.rc)
assert.sameOrderedMembers(res.rc!.environments, environments)
assert.sameOrderedMembers(res.rc.environments, environments)
})

it('should parse command value', (): void => {
Expand All @@ -59,31 +59,31 @@ describe('parseArgs', (): void => {
it('should parse override option', (): void => {
const res = parseArgs(['-e', environments[0], '--no-override', command, ...commandArgs])
assert.exists(res.options)
assert.isTrue(res.options!.noOverride)
assert.isTrue(res.options.noOverride)
})

it('should parse use shell option', (): void => {
const res = parseArgs(['-e', environments[0], '--use-shell', command, ...commandArgs])
assert.exists(res.options)
assert.isTrue(res.options!.useShell)
assert.isTrue(res.options.useShell)
})

it('should parse rc file path', (): void => {
const res = parseArgs(['-e', environments[0], '-r', rcFilePath, command, ...commandArgs])
assert.exists(res.rc)
assert.equal(res.rc!.filePath, rcFilePath)
assert.equal(res.rc.filePath, rcFilePath)
})

it('should parse env file path', (): void => {
const res = parseArgs(['-f', envFilePath, command, ...commandArgs])
assert.exists(res.envFile)
assert.equal(res.envFile!.filePath, envFilePath)
assert.equal(res.envFile.filePath, envFilePath)
})

it('should parse fallback option', (): void => {
const res = parseArgs(['-f', envFilePath, '--fallback', command, ...commandArgs])
assert.exists(res.envFile)
assert.isTrue(res.envFile!.fallback)
assert.isTrue(res.envFile.fallback)
})

it('should print to console.info if --verbose flag is passed', (): void => {
Expand Down
Loading