Skip to content

Commit

Permalink
Revert "get rid of update-notifier completely"
Browse files Browse the repository at this point in the history
This reverts commit 05a5db9.
  • Loading branch information
BYK committed Apr 21, 2021
1 parent 8ed5c38 commit 6090064
Show file tree
Hide file tree
Showing 4 changed files with 369 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"tar": "4.4.8",
"tmp": "0.1.0",
"unzipper": "0.9.7",
"update-notifier": "^5.1.0",
"yargs": "15.1.0"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { readEnvironmentConfig } from './utils/env';
import { isDryRun } from './utils/helpers';
import { hasNoInput, setNoInput } from './utils/noInput';
import { initSentrySdk } from './utils/sentry';
import { getPackageVersion } from './utils/version';
import { checkForUpdates, getPackageVersion } from './utils/version';

// Commands
import * as prepare from './commands/prepare';
Expand Down Expand Up @@ -59,6 +59,8 @@ function printVersion(): void {
* Main entrypoint
*/
function main(): void {
checkForUpdates();

printVersion();

readEnvironmentConfig();
Expand Down
23 changes: 23 additions & 0 deletions src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import updateNotifier from 'update-notifier';

import { getGitTagPrefix } from '../config';

/**
Expand Down Expand Up @@ -133,6 +135,27 @@ export function versionToTag(version: string, tagPrefix?: string): string {
return `${prefix}${version}`;
}

/**
* Checks for latest updates of the "craft" package
*/
export function checkForUpdates(): void {
const pkg = getPackage();

// Notify if the new version is available
const notifier = updateNotifier({
pkg,
updateCheckInterval: 0, // Check immediately
});

if (!notifier.update || pkg.version === notifier.update.latest) {
return;
}

notifier.notify({
defer: false,
});
}

/**
* Reads "package.json" from project root and returns its contents
*/
Expand Down
Loading

0 comments on commit 6090064

Please sign in to comment.