Skip to content

Commit 22854c8

Browse files
committed
added console notifier if update available
1 parent ade5fa8 commit 22854c8

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "create-react-webpack",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "create-react-webpack ",
55
"main": "scripts/create.js",
66
"bin": {
7-
"create-react-webpack": "startApp.sh"
7+
"create-react-webpack": "./start.js"
88
},
99
"preferGlobal": true,
1010
"scripts": {

start.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env node
2+
3+
const child_process = require("child_process");
4+
const path = require("path");
5+
const updateNotifier = require("update-notifier");
6+
const pkg = require("./package.json");
7+
const { ErrorMessage, SuccessMessage } = require("./scripts/helper");
8+
9+
const notifier = updateNotifier({
10+
pkg,
11+
updateCheckInterval: 1000 * 60 * 60 * 24
12+
});
13+
14+
if (notifier.update && notifier.update.latest !== pkg.version) {
15+
const old = notifier.update.current;
16+
const latest = notifier.update.latest;
17+
18+
var message =
19+
`${SuccessMessage("New")} version of ${SuccessMessage(
20+
pkg.name
21+
)} available! ${ErrorMessage(old)} -> ${SuccessMessage(latest)}\n` +
22+
`Run ${SuccessMessage(`npm install -g ${pkg.name}`)} to update!`;
23+
24+
notifier.notify({ message: message });
25+
console.log("______________________________________________________________");
26+
console.log(message);
27+
console.log("______________________________________________________________");
28+
}
29+
var args = process.argv.slice(2);
30+
var dirName = args[0];
31+
var end_to_end = args[1];
32+
33+
var p = path.join(__dirname, "scripts/create.js");
34+
child_process.execSync(`node ${p} ${dirName} ${end_to_end}`, {
35+
stdio: "inherit"
36+
});

startApp.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)