Skip to content

Commit ba12e23

Browse files
authored
Change the network check tool (#31)
1 parent d03814d commit ba12e23

File tree

4 files changed

+15
-26
lines changed

4 files changed

+15
-26
lines changed

bin/gren.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
'use strict';
44

5-
var GithubReleaseNotes = require('../src/gren');
5+
var GithubReleaseNotes = require('./src/gren');
66
var gren = new GithubReleaseNotes();
7-
var utils = require('../src/utils');
8-
7+
var utils = require('./src/utils');
98
var action = utils.getBashOptions(process.argv)['action'];
109

1110
gren.init()
12-
.then(function (success) {
13-
if(success) {
11+
.then(function() {
1412
return gren[action || 'release']();
15-
}
16-
});
13+
});

github-release-notes.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
var GithubReleaseNotes = require('./src/gren');
44
var gren = new GithubReleaseNotes();
55
var utils = require('./src/utils');
6-
76
var action = utils.getBashOptions(process.argv)['action'];
87

98
gren.init()
10-
.then(function (success) {
11-
if(success) {
9+
.then(function() {
1210
return gren[action || 'release']();
13-
}
14-
});
11+
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"homepage": "https://github.com/alexcanessa/github-release-notes#readme",
3434
"dependencies": {
3535
"chalk": "^1.1.3",
36+
"connectivity": "^1.0.0",
3637
"es6-promise": "^3.2.1",
3738
"github-api": "^2.1.0",
3839
"is-online": "^5.1.1",
@@ -41,7 +42,7 @@
4142
"devDependencies": {
4243
"eslint": "^3.6.0",
4344
"eslint-config-standard": "^6.0.1",
44-
"eslint-plugin-promise": "^2.0.1",
45+
"eslint-plugin-promise": "^3.5.0",
4546
"eslint-plugin-standard": "^2.0.0",
4647
"grunt": "^1.0.1",
4748
"grunt-contrib-nodeunit": "^1.0.0",

src/gren.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Github = require('github-api');
66
var fs = require('fs');
77
var chalk = require('chalk');
88
var Promise = Promise || require('es6-promise').Promise;
9-
var isOnline = require('is-online');
9+
var connectivity = require('connectivity');
1010
var ObjectAssign = require('object-assign');
1111

1212
var defaults = {
@@ -749,12 +749,12 @@ function generateOptions(options) {
749749
*/
750750
function hasNetwork() {
751751
return new Promise(function(resolve, reject) {
752-
isOnline(function(err, online) {
753-
if (err) {
754-
reject(chalk.red(err));
752+
connectivity(function(isOnline) {
753+
if (!isOnline) {
754+
reject(chalk.red('You need to have network connectivity'));
755755
}
756756

757-
resolve(online);
757+
resolve(isOnline);
758758
});
759759
});
760760
}
@@ -790,12 +790,8 @@ GithubReleaseNotes.prototype.init = function() {
790790
var gren = this;
791791

792792
return hasNetwork()
793-
.then(function(success) {
794-
if (success) {
795-
return generateOptions(gren.options);
796-
} else {
797-
throw chalk.red('You need to have network connectivity');
798-
}
793+
.then(function() {
794+
return generateOptions(gren.options);
799795
})
800796
.then(function(optionData) {
801797
gren.options = ObjectAssign(...optionData, gren.options);
@@ -810,8 +806,6 @@ GithubReleaseNotes.prototype.init = function() {
810806

811807
gren.repo = githubApi.getRepo(gren.options.username, gren.options.repo);
812808
gren.issues = githubApi.getIssues(gren.options.username, gren.options.repo);
813-
814-
return true;
815809
})
816810
.catch(function(error) {
817811
console.log(error);

0 commit comments

Comments
 (0)