Skip to content

Commit

Permalink
fixup! headlamp-plugin: Make update check asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
illume committed Jun 20, 2024
1 parent ceba257 commit 02359a3
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions plugins/headlamp-plugin/bin/headlamp-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,29 +272,40 @@ function start() {
* Inform if @kinvolk/headlamp-plugin is outdated.
*/
async function informIfOutdated() {
console.log('Checking if @kinvolk/headlamp-plugin is up to date...');
const outdated = getNpmOutdated();
if ('@kinvolk/headlamp-plugin' in outdated) {
const url = `https://github.com/kinvolk/headlamp/releases`;
console.warn(
' @kinvolk/headlamp-plugin is out of date. Run the following command to upgrade \n' +
` See release notes here: ${url}` +
' npx @kinvolk/headlamp-plugin upgrade'
);
} else {
console.log(' @kinvolk/headlamp-plugin is up to date.');
}
console.debug('npm outdated --json process starting');
child_process.exec('npm outdated --json', (error, stdout) => {
console.debug('npm outdated --json process returns');
if (error) {
// npm outdated exit codes 1 when something is not up to date.
const result = stdout.toString();
const outdated = JSON.parse(result);
if ('@kinvolk/headlamp-plugin' in outdated) {
const url = `https://github.com/headlamp-k8s/headlamp/releases`;
console.warn(
' @kinvolk/headlamp-plugin is out of date. Run the following command to upgrade \n' +
` See release notes here: ${url}` +
' npx @kinvolk/headlamp-plugin upgrade'
);
return;
}
}
});
}

informIfOutdated().catch(error => {
console.error('Error checking if @kinvolk/headlamp-plugin is up to date:', error);
});
console.debug('before informIfOutdated');
setTimeout(() => {
informIfOutdated().catch(error => {
console.error('Error checking if @kinvolk/headlamp-plugin is up to date:', error);
});
}, 500);
console.debug('after informIfOutdated');

config.watch = true;
config.mode = 'development';
process.env['BABEL_ENV'] = 'development';
copyToPluginsFolder(config);
let exitCode = 0;
console.debug('webpack starting...');
webpack(config, (err, stats) => {
// We are checking the exit code of the compileMessages function.
// It should be 0 if there are no errors, and 1 if there are errors.
Expand Down

0 comments on commit 02359a3

Please sign in to comment.