Skip to content

Commit

Permalink
Merge pull request #136 from p0rth01998/Minor_Typo
Browse files Browse the repository at this point in the history
Fix: typo update in test & ts lint update
  • Loading branch information
toddbluhm authored May 15, 2020
2 parents ec18721 + 7008403 commit 8f35b71
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/signal-termination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const SIGNALS_TO_HANDLE: NodeJS.Signals[] = [

export class TermSignals {
private readonly terminateSpawnedProcessFuncHandlers: { [key: string]: any } = {}
private readonly verbose: boolean = false;
private readonly verbose: boolean = false
public _exitCalled = false

constructor (options: { verbose?: boolean } = {}) {
Expand Down
8 changes: 4 additions & 4 deletions test/env-cmd.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('EnvCmd', (): void => {
assert.equal(spawnStub.callCount, 1)
})

it('should should override existing env vars if noOverride option is false/missing',
it('should override existing env vars if noOverride option is false/missing',
async (): Promise<void> => {
process.env.BOB = 'cool'
getEnvVarsStub.returns({ BOB: 'test' })
Expand All @@ -113,7 +113,7 @@ describe('EnvCmd', (): void => {
}
)

it('should should not override existing env vars if noOverride option is true',
it('should not override existing env vars if noOverride option is true',
async (): Promise<void> => {
process.env.BOB = 'cool'
getEnvVarsStub.returns({ BOB: 'test' })
Expand All @@ -138,7 +138,7 @@ describe('EnvCmd', (): void => {
}
)

it('should should spawn process with shell option if useShell option is true',
it('should spawn process with shell option if useShell option is true',
async (): Promise<void> => {
process.env.BOB = 'cool'
getEnvVarsStub.returns({ BOB: 'test' })
Expand All @@ -163,7 +163,7 @@ describe('EnvCmd', (): void => {
}
)

it('should should spawn process with command and args expanded if expandEnvs option is true',
it('should spawn process with command and args expanded if expandEnvs option is true',
async (): Promise<void> => {
getEnvVarsStub.returns({ PING: 'PONG', CMD: 'node' })
await envCmdLib.EnvCmd({
Expand Down
38 changes: 19 additions & 19 deletions test/get-env-vars.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe('getEnvVars', (): void => {

it('should parse the json .rc file from the default path with the given environment',
async (): Promise<void> => {
getRCFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getRCFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
const envs = await getEnvVars({ rc: { environments: ['production'] } })
assert.isOk(envs)
assert.lengthOf(Object.keys(envs), 1)
assert.equal(envs.THANKS, 'FORALLTHEFISH')
assert.equal(envs.THANKS, 'FOR ALL THE FISH')
assert.equal(getRCFileVarsStub.callCount, 1)
assert.lengthOf(getRCFileVarsStub.args[0][0].environments, 1)
assert.equal(getRCFileVarsStub.args[0][0].environments[0], 'production')
Expand All @@ -43,7 +43,7 @@ describe('getEnvVars', (): void => {
it('should print path of custom .rc file and environments to info for verbose',
async (): Promise<void> => {
logInfoStub = sinon.stub(console, 'info')
getRCFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getRCFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
await getEnvVars({ rc: { environments: ['production'] }, verbose: true })
assert.equal(logInfoStub.callCount, 1)
}
Expand All @@ -53,11 +53,11 @@ describe('getEnvVars', (): void => {
const pathError = new Error()
pathError.name = 'PathError'
getRCFileVarsStub.rejects(pathError)
getRCFileVarsStub.onThirdCall().returns({ THANKS: 'FORALLTHEFISH' })
getRCFileVarsStub.onThirdCall().returns({ THANKS: 'FOR ALL THE FISH' })
const envs = await getEnvVars({ rc: { environments: ['production'] } })
assert.isOk(envs)
assert.lengthOf(Object.keys(envs), 1)
assert.equal(envs.THANKS, 'FORALLTHEFISH')
assert.equal(envs.THANKS, 'FOR ALL THE FISH')
assert.equal(getRCFileVarsStub.callCount, 3)
assert.lengthOf(getRCFileVarsStub.args[2][0].environments, 1)
assert.equal(getRCFileVarsStub.args[2][0].environments[0], 'production')
Expand Down Expand Up @@ -118,13 +118,13 @@ describe('getEnvVars', (): void => {
})

it('should find .rc file at custom path path', async (): Promise<void> => {
getRCFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getRCFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
const envs = await getEnvVars({
rc: { environments: ['production'], filePath: '../.custom-rc' }
})
assert.isOk(envs)
assert.lengthOf(Object.keys(envs), 1)
assert.equal(envs.THANKS, 'FORALLTHEFISH')
assert.equal(envs.THANKS, 'FOR ALL THE FISH')
assert.equal(getRCFileVarsStub.callCount, 1)
assert.lengthOf(getRCFileVarsStub.args[0][0].environments, 1)
assert.equal(getRCFileVarsStub.args[0][0].environments[0], 'production')
Expand All @@ -133,7 +133,7 @@ describe('getEnvVars', (): void => {

it('should print custom .rc file path to info for verbose', async (): Promise<void> => {
logInfoStub = sinon.stub(console, 'info')
getRCFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getRCFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
await getEnvVars({
rc: { environments: ['production'], filePath: '../.custom-rc' },
verbose: true
Expand Down Expand Up @@ -206,18 +206,18 @@ describe('getEnvVars', (): void => {
)

it('should parse the env file from a custom path', async (): Promise<void> => {
getEnvFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getEnvFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
const envs = await getEnvVars({ envFile: { filePath: '../.env-file' } })
assert.isOk(envs)
assert.lengthOf(Object.keys(envs), 1)
assert.equal(envs.THANKS, 'FORALLTHEFISH')
assert.equal(envs.THANKS, 'FOR ALL THE FISH')
assert.equal(getEnvFileVarsStub.callCount, 1)
assert.equal(getEnvFileVarsStub.args[0][0], '../.env-file')
})

it('should print path of .env file to info for verbose', async (): Promise<void> => {
logInfoStub = sinon.stub(console, 'info')
getEnvFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getEnvFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
await getEnvVars({ envFile: { filePath: '../.env-file' }, verbose: true })
assert.equal(logInfoStub.callCount, 1)
})
Expand Down Expand Up @@ -249,11 +249,11 @@ describe('getEnvVars', (): void => {
'path not found and fallback option provided',
async (): Promise<void> => {
getEnvFileVarsStub.onFirstCall().rejects('File not found.')
getEnvFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getEnvFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
const envs = await getEnvVars({ envFile: { filePath: '../.env-file', fallback: true } })
assert.isOk(envs)
assert.lengthOf(Object.keys(envs), 1)
assert.equal(envs.THANKS, 'FORALLTHEFISH')
assert.equal(envs.THANKS, 'FOR ALL THE FISH')
assert.equal(getEnvFileVarsStub.callCount, 2)
assert.equal(getEnvFileVarsStub.args[1][0], './.env')
}
Expand All @@ -265,36 +265,36 @@ describe('getEnvVars', (): void => {
async (): Promise<void> => {
logInfoStub = sinon.stub(console, 'info')
getEnvFileVarsStub.onFirstCall().rejects('File not found.')
getEnvFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getEnvFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
await getEnvVars({ envFile: { filePath: '../.env-file', fallback: true }, verbose: true })
assert.equal(logInfoStub.callCount, 2)
}
)

it('should parse the env file from the default path', async (): Promise<void> => {
getEnvFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getEnvFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
const envs = await getEnvVars()
assert.isOk(envs)
assert.lengthOf(Object.keys(envs), 1)
assert.equal(envs.THANKS, 'FORALLTHEFISH')
assert.equal(envs.THANKS, 'FOR ALL THE FISH')
assert.equal(getEnvFileVarsStub.callCount, 1)
assert.equal(getEnvFileVarsStub.args[0][0], './.env')
})

it('should print path of .env file to info for verbose', async (): Promise<void> => {
logInfoStub = sinon.stub(console, 'info')
getEnvFileVarsStub.returns({ THANKS: 'FORALLTHEFISH' })
getEnvFileVarsStub.returns({ THANKS: 'FOR ALL THE FISH' })
await getEnvVars({ verbose: true })
assert.equal(logInfoStub.callCount, 1)
})

it('should search all default env file paths', async (): Promise<void> => {
getEnvFileVarsStub.throws('Not found.')
getEnvFileVarsStub.onThirdCall().returns({ THANKS: 'FORALLTHEFISH' })
getEnvFileVarsStub.onThirdCall().returns({ THANKS: 'FOR ALL THE FISH' })
const envs = await getEnvVars()
assert.isOk(envs)
assert.lengthOf(Object.keys(envs), 1)
assert.equal(envs.THANKS, 'FORALLTHEFISH')
assert.equal(envs.THANKS, 'FOR ALL THE FISH')
assert.equal(getEnvFileVarsStub.callCount, 3)
assert.isTrue(getEnvFileVarsStub.calledWithExactly('./.env.json'))
})
Expand Down

0 comments on commit 8f35b71

Please sign in to comment.