-
Notifications
You must be signed in to change notification settings - Fork 2
/
version_check.js
32 lines (27 loc) · 837 Bytes
/
version_check.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const pacote = require('pacote');
const chalk = require('chalk');
const ora = require('ora');
const installedVersion = require('../package.json').version;
const log = require('./log');
module.exports = async () => {
const spinner = ora(chalk.gray('Checking version...'));
spinner.start();
try {
const manifest = await pacote.manifest('@formspree/cli@latest');
const newVersion = manifest.version;
spinner.stop();
if (installedVersion !== newVersion) {
console.log('');
log.progress(
`${chalk.yellow.bold('Update Available!')} ${chalk.gray(
`v${installedVersion} ➜ v${newVersion}`
)}\n Run ${log.variable(
'npm i -g @formspree/cli@latest'
)} to update.\n`
);
}
} catch (e) {
spinner.stop();
log.meta('Version check failed');
}
};