mirror of
https://github.com/toddbluhm/env-cmd.git
synced 2025-12-08 18:23:33 +00:00
Merge pull request #386 from rosslh/master
fix: resolve lint issue in src/parse-rc-file.ts
This commit is contained in:
commit
d428fab7e1
@ -105,9 +105,9 @@ export async function getRCFile (
|
|||||||
}
|
}
|
||||||
if (e.name === 'ParseError') {
|
if (e.name === 'ParseError') {
|
||||||
if (verbose === true) {
|
if (verbose === true) {
|
||||||
console.info(e.message);
|
console.info(e.message)
|
||||||
}
|
}
|
||||||
throw new Error(e.message);
|
throw new Error(e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,10 @@ export async function getRCFileVars (
|
|||||||
parsedData = JSON.parse(file)
|
parsedData = JSON.parse(file)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} 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'
|
parseError.name = 'ParseError'
|
||||||
throw parseError
|
throw parseError
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,13 +27,13 @@ describe('parseArgs', (): void => {
|
|||||||
it('should parse environment value', (): void => {
|
it('should parse environment value', (): void => {
|
||||||
const res = parseArgs(['-e', environments[0], command])
|
const res = parseArgs(['-e', environments[0], command])
|
||||||
assert.exists(res.rc)
|
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 => {
|
it('should parse multiple environment values', (): void => {
|
||||||
const res = parseArgs(['-e', environments.join(','), command])
|
const res = parseArgs(['-e', environments.join(','), command])
|
||||||
assert.exists(res.rc)
|
assert.exists(res.rc)
|
||||||
assert.sameOrderedMembers(res.rc!.environments, environments)
|
assert.sameOrderedMembers(res.rc.environments, environments)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should parse command value', (): void => {
|
it('should parse command value', (): void => {
|
||||||
@ -59,31 +59,31 @@ describe('parseArgs', (): void => {
|
|||||||
it('should parse override option', (): void => {
|
it('should parse override option', (): void => {
|
||||||
const res = parseArgs(['-e', environments[0], '--no-override', command, ...commandArgs])
|
const res = parseArgs(['-e', environments[0], '--no-override', command, ...commandArgs])
|
||||||
assert.exists(res.options)
|
assert.exists(res.options)
|
||||||
assert.isTrue(res.options!.noOverride)
|
assert.isTrue(res.options.noOverride)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should parse use shell option', (): void => {
|
it('should parse use shell option', (): void => {
|
||||||
const res = parseArgs(['-e', environments[0], '--use-shell', command, ...commandArgs])
|
const res = parseArgs(['-e', environments[0], '--use-shell', command, ...commandArgs])
|
||||||
assert.exists(res.options)
|
assert.exists(res.options)
|
||||||
assert.isTrue(res.options!.useShell)
|
assert.isTrue(res.options.useShell)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should parse rc file path', (): void => {
|
it('should parse rc file path', (): void => {
|
||||||
const res = parseArgs(['-e', environments[0], '-r', rcFilePath, command, ...commandArgs])
|
const res = parseArgs(['-e', environments[0], '-r', rcFilePath, command, ...commandArgs])
|
||||||
assert.exists(res.rc)
|
assert.exists(res.rc)
|
||||||
assert.equal(res.rc!.filePath, rcFilePath)
|
assert.equal(res.rc.filePath, rcFilePath)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should parse env file path', (): void => {
|
it('should parse env file path', (): void => {
|
||||||
const res = parseArgs(['-f', envFilePath, command, ...commandArgs])
|
const res = parseArgs(['-f', envFilePath, command, ...commandArgs])
|
||||||
assert.exists(res.envFile)
|
assert.exists(res.envFile)
|
||||||
assert.equal(res.envFile!.filePath, envFilePath)
|
assert.equal(res.envFile.filePath, envFilePath)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should parse fallback option', (): void => {
|
it('should parse fallback option', (): void => {
|
||||||
const res = parseArgs(['-f', envFilePath, '--fallback', command, ...commandArgs])
|
const res = parseArgs(['-f', envFilePath, '--fallback', command, ...commandArgs])
|
||||||
assert.exists(res.envFile)
|
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 => {
|
it('should print to console.info if --verbose flag is passed', (): void => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user