Skip to content

Commit

Permalink
Framework: Provide messaging for fetch connectivity error
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Apr 7, 2020
1 parent 40703df commit aac7243
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
26 changes: 22 additions & 4 deletions bin/check-latest-npm.js
Expand Up @@ -52,7 +52,24 @@ async function getLatestNPMVersion() {

resolve( data[ 'dist-tags' ].latest );
}
);
).on( 'error', ( error ) => {
if (
/** @type {NodeJS.ErrnoException} */ ( error ).code ===
'ENOTFOUND'
) {
error = new Error( `Could not contact the NPM registry to determine latest version.
This could be due to an intermittent outage of the service, or because you are not connected to the internet.
Because it is important that \`package-lock.json\` files only be committed while running the latest version of NPM, this commit has been blocked.
If you are certain of your changes and desire to commit anyways, you should either connect to the internet or bypass commit verification using ${ yellow(
'git commit --no-verify'
) } .` );
}

reject( error );
} );
} );
}

Expand Down Expand Up @@ -85,15 +102,16 @@ Promise.all( [ getLatestNPMVersion(), getLocalNPMVersion() ] )
It is required that you have the latest version of NPM installed in order to commit a change to the package-lock.json file.
Run ${ yellow( 'npm install --global npm@latest' ) }, then try again.
`
Run ${ yellow( 'npm install --global npm@latest' ) }, then try again.`
);
}
} )
.catch( ( error ) => {
// Disable reason: A failure should log to the terminal.

// eslint-disable-next-line no-console
console.error( 'Latest NPM check failed!\n\n' + error.toString() );
console.error(
'Latest NPM check failed!\n\n' + error.toString() + '\n'
);
process.exitCode = 1;
} );
1 change: 1 addition & 0 deletions packages/eslint-plugin/configs/jsdoc.js
Expand Up @@ -61,6 +61,7 @@ const typescriptUtilityTypes = [
'ThisType',
'unknown',
'never',
'NodeJS',
];

module.exports = {
Expand Down

0 comments on commit aac7243

Please sign in to comment.