-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdateCheck.js
36 lines (34 loc) · 1.25 KB
/
updateCheck.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
33
34
35
36
const colors = require("colors/safe");
const checkForUpdate = require("update-check");
const updateCheck = async (pkg, hrs) => {
try {
const update = await checkForUpdate(pkg);
if (update) {
process.on("exit", () => {
console.log(
colors.cyan(
"\n╔══════════════════════════════════════════════════════════╗"
)
);
console.log(
colors.cyan("║ ") +
`Update available ${colors.red(
pkg.version
)} \u2192 ${colors.brightGreen(update.latest)}` +
colors.cyan(" ║")
);
console.log(
colors.cyan("║ ") +
`Run ${colors.brightBlue("npm i -g " + pkg.name)} to update` +
colors.cyan(" ║")
);
console.log(
colors.cyan(
"╚══════════════════════════════════════════════════════════╝\n"
)
);
});
}
} catch (err) {}
};
module.exports = updateCheck;