From a253a62232fa80af52d5ad4ec48da192a78d606a Mon Sep 17 00:00:00 2001 From: Todd Bluhm Date: Sun, 9 Feb 2020 20:40:20 -0600 Subject: [PATCH] chore(package): update devDependencies - fix new lint errors - fix missing code coverage - update ignore files --- .gitignore | 1 + .npmignore | 3 ++- dist/get-env-vars.js | 12 ++++++------ dist/parse-rc-file.js | 2 +- dist/signal-termination.js | 9 ++++++--- package.json | 11 ++++++++--- src/get-env-vars.ts | 12 ++++++------ src/parse-rc-file.ts | 2 +- src/signal-termination.ts | 10 +++++++--- test/signal-termination.spec.ts | 14 ++++++++++++++ 10 files changed, 52 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index a0d992f..e5ee25a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ package-lock.json # Code Editor directory .vscode +.idea # Ignore compiled dist/tests dist/test diff --git a/.npmignore b/.npmignore index af95e67..140dc19 100644 --- a/.npmignore +++ b/.npmignore @@ -1,10 +1,11 @@ .DS_Store .nyc_output .vscode +.idea coverage/ node_modules/ src/ test/ *.yml tsconfig.json -tsconfig.eslint.json \ No newline at end of file +tsconfig.eslint.json diff --git a/dist/get-env-vars.js b/dist/get-env-vars.js index 9dd5403..dea1338 100644 --- a/dist/get-env-vars.js +++ b/dist/get-env-vars.js @@ -51,7 +51,7 @@ async function getEnvFile({ filePath, fallback, verbose }) { } catch (e) { } } - const error = `Failed to find .env file at default paths: ${ENV_FILE_DEFAULT_LOCATIONS}`; + const error = `Failed to find .env file at default paths: [${ENV_FILE_DEFAULT_LOCATIONS.join(',')}]`; if (verbose === true) { console.info(error); } @@ -64,7 +64,7 @@ async function getRCFile({ environments, filePath, verbose }) { try { const env = await parse_rc_file_1.getRCFileVars({ environments, filePath }); if (verbose === true) { - console.info(`Found environments: ${environments} for .rc file at path: ${filePath}`); + console.info(`Found environments: [${environments.join(',')}] for .rc file at path: ${filePath}`); } return env; } @@ -76,7 +76,7 @@ async function getRCFile({ environments, filePath, verbose }) { } if (e.name === 'EnvironmentError') { if (verbose === true) { - console.info(`Failed to find environments: ${environments} for .rc file at path: ${filePath}`); + console.info(`Failed to find environments: [${environments.join(',')}] for .rc file at path: ${filePath}`); } } throw e; @@ -87,13 +87,13 @@ async function getRCFile({ environments, filePath, verbose }) { try { const env = await parse_rc_file_1.getRCFileVars({ environments, filePath: path }); if (verbose === true) { - console.info(`Found environments: ${environments} for default .rc file at path: ${path}`); + console.info(`Found environments: [${environments.join(',')}] for default .rc file at path: ${path}`); } return env; } catch (e) { if (e.name === 'EnvironmentError') { - const errorText = `Failed to find environments: ${environments} for .rc file at path: ${path}`; + const errorText = `Failed to find environments: [${environments.join(',')}] for .rc file at path: ${path}`; if (verbose === true) { console.info(errorText); } @@ -101,7 +101,7 @@ async function getRCFile({ environments, filePath, verbose }) { } } } - const errorText = `Failed to find .rc file at default paths: ${RC_FILE_DEFAULT_LOCATIONS}`; + const errorText = `Failed to find .rc file at default paths: [${RC_FILE_DEFAULT_LOCATIONS.join(',')}]`; if (verbose === true) { console.info(errorText); } diff --git a/dist/parse-rc-file.js b/dist/parse-rc-file.js index b247a01..5e7b46b 100644 --- a/dist/parse-rc-file.js +++ b/dist/parse-rc-file.js @@ -48,7 +48,7 @@ async function getRCFileVars({ environments, filePath }) { } }); if (!environmentFound) { - const environmentError = new Error(`Failed to find environments ${environments} at .rc file location: ${absolutePath}`); + const environmentError = new Error(`Failed to find environments [${environments.join(',')}] at .rc file location: ${absolutePath}`); environmentError.name = 'EnvironmentError'; throw environmentError; } diff --git a/dist/signal-termination.js b/dist/signal-termination.js index f0b6f44..6517239 100644 --- a/dist/signal-termination.js +++ b/dist/signal-termination.js @@ -18,7 +18,9 @@ class TermSignals { this._removeProcessListeners(); if (!this._exitCalled) { if (this.verbose) { - console.info(`Parent process exited with signal: ${signal}. Terminating child process...`); + console.info('Parent process exited with signal: ' + + signal.toString() + + '. Terminating child process...'); } // Mark shared state so we do not run into a signal/exit loop this._exitCalled = true; @@ -47,8 +49,9 @@ class TermSignals { this._removeProcessListeners(); if (!this._exitCalled) { if (this.verbose) { - console.info(`Child process exited with code: ${code} and signal: ${signal}. ` + - 'Terminating parent process...'); + console.info(`Child process exited with code: ${((code !== null && code !== void 0 ? code : '')).toString()} and signal:` + + ((signal !== null && signal !== void 0 ? signal : '')).toString() + + '. Terminating parent process...'); } // Mark shared state so we do not run into a signal/exit loop this._exitCalled = true; diff --git a/package.json b/package.json index 7b7a06a..2994803 100644 --- a/package.json +++ b/package.json @@ -53,16 +53,16 @@ "devDependencies": { "@types/chai": "^4.0.0", "@types/cross-spawn": "^6.0.0", - "@types/mocha": "^5.0.0", + "@types/mocha": "^7.0.0", "@types/node": "^12.0.0", "@types/sinon": "^7.0.0", "chai": "^4.0.0", "coveralls": "^3.0.0", - "mocha": "^6.0.0", + "mocha": "^7.0.0", "nyc": "^15.0.0", "sinon": "^8.0.0", "ts-node": "^8.0.0", - "ts-standard": "^3.0.0", + "ts-standard": "^4.0.0", "typescript": "^3.7.0" }, "nyc": { @@ -87,5 +87,10 @@ "ignore": [ "dist" ] + }, + "greenkeeper": { + "ignore": [ + "@types/node" + ] } } diff --git a/src/get-env-vars.ts b/src/get-env-vars.ts index 102b5ff..746e7d7 100644 --- a/src/get-env-vars.ts +++ b/src/get-env-vars.ts @@ -54,7 +54,7 @@ export async function getEnvFile ( } catch (e) { } } - const error = `Failed to find .env file at default paths: ${ENV_FILE_DEFAULT_LOCATIONS}` + const error = `Failed to find .env file at default paths: [${ENV_FILE_DEFAULT_LOCATIONS.join(',')}]` if (verbose === true) { console.info(error) } @@ -69,7 +69,7 @@ export async function getRCFile ( try { const env = await getRCFileVars({ environments, filePath }) if (verbose === true) { - console.info(`Found environments: ${environments} for .rc file at path: ${filePath}`) + console.info(`Found environments: [${environments.join(',')}] for .rc file at path: ${filePath}`) } return env } catch (e) { @@ -80,7 +80,7 @@ export async function getRCFile ( } if (e.name === 'EnvironmentError') { if (verbose === true) { - console.info(`Failed to find environments: ${environments} for .rc file at path: ${filePath}`) + console.info(`Failed to find environments: [${environments.join(',')}] for .rc file at path: ${filePath}`) } } throw e @@ -92,12 +92,12 @@ export async function getRCFile ( try { const env = await getRCFileVars({ environments, filePath: path }) if (verbose === true) { - console.info(`Found environments: ${environments} for default .rc file at path: ${path}`) + console.info(`Found environments: [${environments.join(',')}] for default .rc file at path: ${path}`) } return env } catch (e) { if (e.name === 'EnvironmentError') { - const errorText = `Failed to find environments: ${environments} for .rc file at path: ${path}` + const errorText = `Failed to find environments: [${environments.join(',')}] for .rc file at path: ${path}` if (verbose === true) { console.info(errorText) } @@ -106,7 +106,7 @@ export async function getRCFile ( } } - const errorText = `Failed to find .rc file at default paths: ${RC_FILE_DEFAULT_LOCATIONS}` + const errorText = `Failed to find .rc file at default paths: [${RC_FILE_DEFAULT_LOCATIONS.join(',')}]` if (verbose === true) { console.info(errorText) } diff --git a/src/parse-rc-file.ts b/src/parse-rc-file.ts index 3370062..1ea7cf0 100644 --- a/src/parse-rc-file.ts +++ b/src/parse-rc-file.ts @@ -55,7 +55,7 @@ export async function getRCFileVars ( if (!environmentFound) { const environmentError = new Error( - `Failed to find environments ${environments} at .rc file location: ${absolutePath}` + `Failed to find environments [${environments.join(',')}] at .rc file location: ${absolutePath}` ) environmentError.name = 'EnvironmentError' throw environmentError diff --git a/src/signal-termination.ts b/src/signal-termination.ts index b65c74b..5f47469 100644 --- a/src/signal-termination.ts +++ b/src/signal-termination.ts @@ -21,7 +21,10 @@ export class TermSignals { this._removeProcessListeners() if (!this._exitCalled) { if (this.verbose) { - console.info(`Parent process exited with signal: ${signal}. Terminating child process...`) + console.info( + 'Parent process exited with signal: ' + + signal.toString() + + '. Terminating child process...') } // Mark shared state so we do not run into a signal/exit loop this._exitCalled = true @@ -51,8 +54,9 @@ export class TermSignals { if (!this._exitCalled) { if (this.verbose) { console.info( - `Child process exited with code: ${code} and signal: ${signal}. ` + - 'Terminating parent process...' + `Child process exited with code: ${(code ?? '').toString()} and signal:` + + (signal ?? '').toString() + + '. Terminating parent process...' ) } // Mark shared state so we do not run into a signal/exit loop diff --git a/test/signal-termination.spec.ts b/test/signal-termination.spec.ts index a4aa7ee..f203ff9 100644 --- a/test/signal-termination.spec.ts +++ b/test/signal-termination.spec.ts @@ -244,6 +244,20 @@ describe('signal-termination', (): void => { assert.equal(logInfoStub.callCount, 1) }) + it( + 'should print parent process terminated to info for verbose when ' + + 'code and signal are undefined', + (): void => { + sandbox.restore() + setup(true) + logInfoStub = sandbox.stub(console, 'info') + assert.notOk(term._exitCalled) + term.handleTermSignals(proc) + procOnStub.args[0][1](undefined, null) + assert.equal(logInfoStub.callCount, 1) + } + ) + it('should not terminate parent process if parent process already terminating', (): void => { assert.notOk(term._exitCalled) term.handleTermSignals(proc)