@iexec/iapp
Version:
A CLI to guide you through the process of building an iExec iApp
22 lines • 910 B
JavaScript
import { default as updateCheck } from 'update-check';
import { createRequire } from 'module';
import { command } from './color.js';
import { sleep } from '../utils/sleep.js';
import { hintBox } from './box.js';
const require = createRequire(import.meta.url);
const pkg = require('../../package.json');
export async function checkPackageUpdate() {
const updateCheckPromise = updateCheck(pkg).catch(() => {
// silently fail
return undefined;
});
const timeoutPromise = sleep(3000);
const update = await Promise.race([updateCheckPromise, timeoutPromise]);
if (update?.latest) {
const updateCommand = `npm i -g ${pkg?.name}`;
// eslint-disable-next-line no-console
console.log(hintBox(`iApp generator update available ${pkg?.version} → ${update.latest}
Run ${command(updateCommand)} to update`));
}
}
//# sourceMappingURL=checkPackageUpdate.js.map