Skip to content

Commit 623dfa0

Browse files
committed
Use prettier
1 parent 93b16c0 commit 623dfa0

File tree

12 files changed

+338
-182
lines changed

12 files changed

+338
-182
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/package.json
2+
/CHANGES.md

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "none"
4+
}

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3-
- "8"
4-
- "10"
5-
- "12"
3+
- '8'
4+
- '10'
5+
- '12'

lib/changelog.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ function parseAuthor(author) {
1414
return m ? author.substring(0, m.index).trim() : author;
1515
}
1616

17-
module.exports = function ({
18-
log_range,
19-
commits,
20-
newline,
21-
pkg
22-
}) {
23-
17+
module.exports = function ({ log_range, commits, newline, pkg }) {
2418
let flags = '--format="» ';
2519
if (commits) {
2620
commits = commits.replace(VARIABLE_RE, (match, key) => pkg[key]);
@@ -53,9 +47,8 @@ module.exports = function ({
5347
// Only mention contributors
5448
const { author } = pkg;
5549
if (author) {
56-
const author_name = typeof author === 'object'
57-
? author.name
58-
: parseAuthor(author);
50+
const author_name =
51+
typeof author === 'object' ? author.name : parseAuthor(author);
5952
changes = changes.replace(new RegExp(` \\(${author_name}\\)$`, 'gm'), '');
6053
}
6154

lib/changes.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ exports.write = function (options, callback) {
9898
pkg.homepage = info.browse();
9999
}
100100
if (!pkg.homepage) {
101-
console.error('--commits option requires base URL, "repository" or '
102-
+ '"homepage" in package.json\n');
101+
console.error(
102+
'--commits option requires base URL, "repository" or ' +
103+
'"homepage" in package.json\n'
104+
);
103105
process.exit(1);
104106
return;
105107
}
@@ -114,7 +116,6 @@ exports.write = function (options, callback) {
114116
});
115117

116118
function write() {
117-
118119
// Do not allow version to be added twice
119120
if (exists(previous, version)) {
120121
console.error(`Version ${version} is already in ${changes_file}\n`);

lib/github.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@
88
const request = require('@studio/json-request');
99

1010
exports.fetchUserHomepage = function (email, callback) {
11-
request({
12-
hostname: 'api.github.com',
13-
path: `/search/users?q=${encodeURIComponent(email)}&in=email`,
14-
headers: {
15-
'User-Agent': '@studio/changes'
11+
request(
12+
{
13+
hostname: 'api.github.com',
14+
path: `/search/users?q=${encodeURIComponent(email)}&in=email`,
15+
headers: {
16+
'User-Agent': '@studio/changes'
17+
},
18+
timeout: 5000
1619
},
17-
timeout: 5000
18-
}, (err, json) => {
19-
if (err) {
20-
callback(err, json);
21-
return;
20+
(err, json) => {
21+
if (err) {
22+
callback(err, json);
23+
return;
24+
}
25+
if (json.items && json.items.length === 1) {
26+
callback(null, json.items[0].html_url);
27+
} else {
28+
callback(null, null);
29+
}
2230
}
23-
if (json.items && json.items.length === 1) {
24-
callback(null, json.items[0].html_url);
25-
} else {
26-
callback(null, null);
27-
}
28-
});
31+
);
2932
};

lib/init.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ module.exports = function (argv) {
3737
if (argv.commits) {
3838
if (typeof argv.commits === 'boolean') {
3939
if (!pkg.homepage) {
40-
console.error('--commits option requires base URL or "homepage" in '
41-
+ 'package.json\n');
40+
console.error(
41+
'--commits option requires base URL or "homepage" in ' +
42+
'package.json\n'
43+
);
4244
return false;
4345
}
4446
} else {

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"eslint": "^7.19.0",
4949
"eslint-plugin-mocha": "^8.0.0",
5050
"eslint-plugin-node": "^11.1.0",
51-
"mocha": "^8.2.1"
51+
"mocha": "^8.2.1",
52+
"prettier": "^2.2.1"
5253
},
5354
"repository": {
5455
"type": "git",

0 commit comments

Comments
 (0)