Skip to content

Commit 4430720

Browse files
committed
Updated dev dependencies and formatting
1 parent 75809af commit 4430720

17 files changed

+1697
-1771
lines changed

bin/gh-pages-clean.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
const ghpages = require('../lib/index');
3+
const ghpages = require('../lib/index.js');
44

55
function main() {
66
ghpages.clean();

bin/gh-pages.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
const ghpages = require('../lib/index');
3+
const ghpages = require('../lib/index.js');
44
const program = require('commander');
55
const path = require('path');
66
const pkg = require('../package.json');
@@ -9,7 +9,7 @@ const addr = require('email-addresses');
99
function publish(config) {
1010
return new Promise((resolve, reject) => {
1111
const basePath = path.resolve(process.cwd(), program.dist);
12-
ghpages.publish(basePath, config, err => {
12+
ghpages.publish(basePath, config, (err) => {
1313
if (err) {
1414
return reject(err);
1515
}
@@ -90,7 +90,7 @@ function main(args) {
9090
let beforeAdd;
9191
if (program.beforeAdd) {
9292
const m = require(require.resolve(program.beforeAdd, {
93-
paths: [process.cwd()]
93+
paths: [process.cwd()],
9494
}));
9595

9696
if (typeof m === 'function') {
@@ -122,7 +122,7 @@ function main(args) {
122122
push: !!program.push,
123123
history: !!program.history,
124124
user: user,
125-
beforeAdd: beforeAdd
125+
beforeAdd: beforeAdd,
126126
};
127127

128128
return publish(config);
@@ -134,9 +134,10 @@ if (require.main === module) {
134134
.then(() => {
135135
process.stdout.write('Published\n');
136136
})
137-
.catch(err => {
137+
.catch((err) => {
138138
process.stderr.write(`${err.message}\n`, () => process.exit(1));
139139
});
140140
}
141141

142-
exports = module.exports = main;
142+
module.exports = main;
143+
exports = module.exports;

lib/git.js

+34-32
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require('path');
44
const util = require('util');
55

66
/**
7-
* @constructor
7+
* @function Object() { [native code] }
88
* @param {number} code Error code.
99
* @param {string} message Error message.
1010
*/
@@ -21,21 +21,21 @@ util.inherits(ProcessError, Error);
2121
/**
2222
* Util function for handling spawned processes as promises.
2323
* @param {string} exe Executable.
24-
* @param {Array.<string>} args Arguments.
24+
* @param {Array<string>} args Arguments.
2525
* @param {string} cwd Working directory.
2626
* @return {Promise} A promise.
2727
*/
2828
function spawn(exe, args, cwd) {
2929
return new Promise((resolve, reject) => {
3030
const child = cp.spawn(exe, args, {cwd: cwd || process.cwd()});
3131
const buffer = [];
32-
child.stderr.on('data', chunk => {
32+
child.stderr.on('data', (chunk) => {
3333
buffer.push(chunk.toString());
3434
});
35-
child.stdout.on('data', chunk => {
35+
child.stdout.on('data', (chunk) => {
3636
buffer.push(chunk.toString());
3737
});
38-
child.on('close', code => {
38+
child.on('close', (code) => {
3939
const output = buffer.join('');
4040
if (code) {
4141
const msg = output || 'Process failed: ' + code;
@@ -50,8 +50,8 @@ function spawn(exe, args, cwd) {
5050
/**
5151
* Create an object for executing git commands.
5252
* @param {string} cwd Repository directory.
53-
* @param {string} exe Git executable (full path if not already on path).
54-
* @constructor
53+
* @param {string} cmd Git executable (full path if not already on path).
54+
* @function Object() { [native code] }
5555
*/
5656
function Git(cwd, cmd) {
5757
this.cwd = cwd;
@@ -61,12 +61,12 @@ function Git(cwd, cmd) {
6161

6262
/**
6363
* Execute an arbitrary git command.
64-
* @param {string} var_args Arguments (e.g. 'remote', 'update').
64+
* @param {Array<string>} args Arguments (e.g. ['remote', 'update']).
6565
* @return {Promise} A promise. The promise will be resolved with this instance
6666
* or rejected with an error.
6767
*/
68-
Git.prototype.exec = function() {
69-
return spawn(this.cmd, [...arguments], this.cwd).then(output => {
68+
Git.prototype.exec = function (...args) {
69+
return spawn(this.cmd, [...args], this.cwd).then((output) => {
7070
this.output = output;
7171
return this;
7272
});
@@ -76,15 +76,15 @@ Git.prototype.exec = function() {
7676
* Initialize repository.
7777
* @return {Promise} A promise.
7878
*/
79-
Git.prototype.init = function() {
79+
Git.prototype.init = function () {
8080
return this.exec('init');
8181
};
8282

8383
/**
8484
* Clean up unversioned files.
8585
* @return {Promise} A promise.
8686
*/
87-
Git.prototype.clean = function() {
87+
Git.prototype.clean = function () {
8888
return this.exec('clean', '-f', '-d');
8989
};
9090

@@ -94,7 +94,7 @@ Git.prototype.clean = function() {
9494
* @param {string} branch Branch name.
9595
* @return {Promise} A promise.
9696
*/
97-
Git.prototype.reset = function(remote, branch) {
97+
Git.prototype.reset = function (remote, branch) {
9898
return this.exec('reset', '--hard', remote + '/' + branch);
9999
};
100100

@@ -103,7 +103,7 @@ Git.prototype.reset = function(remote, branch) {
103103
* @param {string} remote Remote alias.
104104
* @return {Promise} A promise.
105105
*/
106-
Git.prototype.fetch = function(remote) {
106+
Git.prototype.fetch = function (remote) {
107107
return this.exec('fetch', remote);
108108
};
109109

@@ -113,7 +113,7 @@ Git.prototype.fetch = function(remote) {
113113
* @param {string} branch Branch name.
114114
* @return {Promise} A promise.
115115
*/
116-
Git.prototype.checkout = function(remote, branch) {
116+
Git.prototype.checkout = function (remote, branch) {
117117
const treeish = remote + '/' + branch;
118118
return this.exec('ls-remote', '--exit-code', '.', treeish).then(
119119
() => {
@@ -122,7 +122,7 @@ Git.prototype.checkout = function(remote, branch) {
122122
.then(() => this.clean())
123123
.then(() => this.reset(remote, branch));
124124
},
125-
error => {
125+
(error) => {
126126
if (error instanceof ProcessError && error.code === 2) {
127127
// branch doesn't exist, create an orphan
128128
return this.exec('checkout', '--orphan', branch);
@@ -136,10 +136,10 @@ Git.prototype.checkout = function(remote, branch) {
136136

137137
/**
138138
* Remove all unversioned files.
139-
* @param {string|string[]} files Files argument.
139+
* @param {string | Array<string>} files Files argument.
140140
* @return {Promise} A promise.
141141
*/
142-
Git.prototype.rm = function(files) {
142+
Git.prototype.rm = function (files) {
143143
if (!Array.isArray(files)) {
144144
files = [files];
145145
}
@@ -148,10 +148,10 @@ Git.prototype.rm = function(files) {
148148

149149
/**
150150
* Add files.
151-
* @param {string|string[]} files Files argument.
151+
* @param {string | Array<string>} files Files argument.
152152
* @return {Promise} A promise.
153153
*/
154-
Git.prototype.add = function(files) {
154+
Git.prototype.add = function (files) {
155155
if (!Array.isArray(files)) {
156156
files = [files];
157157
}
@@ -163,7 +163,7 @@ Git.prototype.add = function(files) {
163163
* @param {string} message Commit message.
164164
* @return {Promise} A promise.
165165
*/
166-
Git.prototype.commit = function(message) {
166+
Git.prototype.commit = function (message) {
167167
return this.exec('diff-index', '--quiet', 'HEAD').catch(() =>
168168
this.exec('commit', '-m', message)
169169
);
@@ -174,7 +174,7 @@ Git.prototype.commit = function(message) {
174174
* @param {string} name Name of tag.
175175
* @return {Promise} A promise.
176176
*/
177-
Git.prototype.tag = function(name) {
177+
Git.prototype.tag = function (name) {
178178
return this.exec('tag', name);
179179
};
180180

@@ -185,7 +185,7 @@ Git.prototype.tag = function(name) {
185185
* @param {boolean} force Force push.
186186
* @return {Promise} A promise.
187187
*/
188-
Git.prototype.push = function(remote, branch, force) {
188+
Git.prototype.push = function (remote, branch, force) {
189189
const args = ['push', '--tags', remote, branch];
190190
if (force) {
191191
args.push('--force');
@@ -198,9 +198,9 @@ Git.prototype.push = function(remote, branch, force) {
198198
* @param {string} remote Remote alias.
199199
* @return {Promise<string>} A promise for the remote URL.
200200
*/
201-
Git.prototype.getRemoteUrl = function(remote) {
201+
Git.prototype.getRemoteUrl = function (remote) {
202202
return this.exec('config', '--get', 'remote.' + remote + '.url')
203-
.then(git => {
203+
.then((git) => {
204204
const repo = git.output && git.output.split(/[\n\r]/).shift();
205205
if (repo) {
206206
return repo;
@@ -210,7 +210,7 @@ Git.prototype.getRemoteUrl = function(remote) {
210210
);
211211
}
212212
})
213-
.catch(err => {
213+
.catch((err) => {
214214
throw new Error(
215215
'Failed to get remote.' +
216216
remote +
@@ -225,9 +225,11 @@ Git.prototype.getRemoteUrl = function(remote) {
225225

226226
/**
227227
* Delete ref to remove branch history
228-
* @param {string} branch
228+
* @param {string} branch The branch name.
229+
* @return {Promise} A promise. The promise will be resolved with this instance
230+
* or rejected with an error.
229231
*/
230-
Git.prototype.deleteRef = function(branch) {
232+
Git.prototype.deleteRef = function (branch) {
231233
return this.exec('update-ref', '-d', 'refs/heads/' + branch);
232234
};
233235

@@ -240,7 +242,7 @@ Git.prototype.deleteRef = function(branch) {
240242
* @return {Promise<Git>} A promise.
241243
*/
242244
Git.clone = function clone(repo, dir, branch, options) {
243-
return fs.exists(dir).then(exists => {
245+
return fs.exists(dir).then((exists) => {
244246
if (exists) {
245247
return Promise.resolve(new Git(dir, options.git));
246248
} else {
@@ -255,17 +257,17 @@ Git.clone = function clone(repo, dir, branch, options) {
255257
'--origin',
256258
options.remote,
257259
'--depth',
258-
options.depth
260+
options.depth,
259261
];
260262
return spawn(options.git, args)
261-
.catch(err => {
263+
.catch((err) => {
262264
// try again without branch or depth options
263265
return spawn(options.git, [
264266
'clone',
265267
repo,
266268
dir,
267269
'--origin',
268-
options.remote
270+
options.remote,
269271
]);
270272
})
271273
.then(() => new Git(dir, options.git));

0 commit comments

Comments
 (0)