Skip to content

Commit 20f2b1e

Browse files
committed
ESLint style fixes
All changes resulted from `eslint --fix .`. Signed-off-by: Kevin Locke <[email protected]>
1 parent 7a7d2ac commit 20f2b1e

File tree

9 files changed

+49
-50
lines changed

9 files changed

+49
-50
lines changed

bin/git-branch-is.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
'use strict';
88

9-
const {Command} = require('commander');
9+
const { Command } = require('commander');
1010

1111
const gitBranchIs = require('..');
1212
const packageJson = require('../package.json');
@@ -59,7 +59,7 @@ function gitBranchIsCmd(args, callback) {
5959
.option('-C <path>', 'run as if started in <path>')
6060
.option(
6161
'--git-arg <arg>', 'additional argument to git (can be repeated)',
62-
collect, []
62+
collect, [],
6363
)
6464
.option('--git-dir <dir>', 'set the path to the repository')
6565
.option('--git-path <path>', 'set the path to the git binary')
@@ -96,13 +96,13 @@ function gitBranchIsCmd(args, callback) {
9696
try {
9797
expectedBranchRegExp = new RegExp(
9898
expectedBranch,
99-
command.ignoreCase ? 'i' : undefined
99+
command.ignoreCase ? 'i' : undefined,
100100
);
101101
} catch (errRegExp) {
102102
callback(null, {
103103
code: 2,
104104
stderr: `Error: Invalid RegExp "${expectedBranch}": ${
105-
errRegExp}\n`
105+
errRegExp}\n`,
106106
});
107107
return undefined;
108108
}
@@ -147,7 +147,7 @@ function gitBranchIsCmd(args, callback) {
147147
stderr: errMsg && `Error: ${errMsg}`,
148148
stdout: isMatch && command.verbose
149149
? `Current branch is "${currentBranch}".\n`
150-
: null
150+
: null,
151151
});
152152
});
153153
return undefined;

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'use strict';
77

8-
const {execFile} = require('child_process');
8+
const { execFile } = require('child_process');
99

1010
/** Options for {@link gitBranchIs}.
1111
*
@@ -27,7 +27,7 @@ const GitBranchIsOptions = {
2727
cwd: '',
2828
gitArgs: [],
2929
gitDir: '',
30-
gitPath: 'git'
30+
gitPath: 'git',
3131
};
3232

3333
/** Checks that the current branch of a git repository has a given name.
@@ -125,7 +125,7 @@ gitBranchIs.getBranch = function getBranch(options, callback) {
125125
Object.keys(GitBranchIsOptions).forEach((prop) => {
126126
combinedOpts[prop] = GitBranchIsOptions[prop];
127127
});
128-
Object.keys(Object(options)).forEach((prop) => {
128+
Object.keys(new Object(options)).forEach((prop) => {
129129
combinedOpts[prop] = options[prop];
130130
});
131131

@@ -141,7 +141,7 @@ gitBranchIs.getBranch = function getBranch(options, callback) {
141141
execFile(
142142
combinedOpts.gitPath,
143143
gitArgs,
144-
{cwd: combinedOpts.cwd},
144+
{ cwd: combinedOpts.cwd },
145145
(errExec, stdout, stderr) => {
146146
if (errExec) {
147147
callback(errExec);
@@ -151,7 +151,7 @@ gitBranchIs.getBranch = function getBranch(options, callback) {
151151
// Note: ASCII space and control characters are forbidden in names
152152
// https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
153153
callback(null, stdout.trimRight());
154-
}
154+
},
155155
);
156156
} catch (errExec) {
157157
process.nextTick(callback, errExec);

test-bin/echo-surprise.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env node
21

32
'use strict';
43

test-lib/assert-match.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function assertMatch(value, regexp, message) {
1717
value = String(value);
1818
assert(
1919
regexp.test(value),
20-
message || `${JSON.stringify(value)} does not match ${regexp}`
20+
message || `${JSON.stringify(value)} does not match ${regexp}`,
2121
);
2222
}
2323

test-lib/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ module.exports = Object.freeze({
2020
/** Name of a subdirectory to create within the git repo. */
2121
SUBDIR_NAME: 'subdir',
2222
/** Path to repository in which tests are run. */
23-
TEST_REPO_PATH: path.join(__dirname, '..', 'test-repo')
23+
TEST_REPO_PATH: path.join(__dirname, '..', 'test-repo'),
2424
});

test-lib/git.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
'use strict';
77

8-
const {execFile} = require('child_process');
8+
const { execFile } = require('child_process');
99
const pify = require('pify');
1010

11-
const execFileP = pify(execFile, {multiArgs: true});
11+
const execFileP = pify(execFile, { multiArgs: true });
1212

1313
/**
1414
* Run git with given arguments and options.
@@ -27,7 +27,7 @@ function git(...args) {
2727
options.stdio = options.stdio || defaultStdio;
2828
} else {
2929
options = {
30-
stdio: defaultStdio
30+
stdio: defaultStdio,
3131
};
3232
}
3333

test/git-branch-is-cmd.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
const assert = require('assert');
10-
const {execFile} = require('child_process');
10+
const { execFile } = require('child_process');
1111
const path = require('path');
1212

1313
const assertMatch = require('../test-lib/assert-match');
@@ -18,7 +18,7 @@ const gitBranchIsCmd = require('../bin/git-branch-is');
1818
const ARGS = [process.argv[0], 'git-branch-is'];
1919

2020
// Local copy of shared constants
21-
const {BRANCH_CURRENT, SUBDIR_NAME, TEST_REPO_PATH} = constants;
21+
const { BRANCH_CURRENT, SUBDIR_NAME, TEST_REPO_PATH } = constants;
2222

2323
const BRANCH_CURRENT_RE = new RegExp(`\\b${constants.BRANCH_CURRENT}\\b`);
2424

@@ -240,7 +240,7 @@ describe('git-branch-is', () => {
240240
'-C',
241241
SUBDIR_NAME,
242242
'--git-arg=--git-dir=../.git',
243-
BRANCH_CURRENT
243+
BRANCH_CURRENT,
244244
);
245245
gitBranchIsCmd(args, (err, result) => {
246246
assert.ifError(err);
@@ -257,7 +257,7 @@ describe('git-branch-is', () => {
257257
'..',
258258
'--git-arg=-C',
259259
`--git-arg=${TEST_REPO_PATH}`,
260-
BRANCH_CURRENT
260+
BRANCH_CURRENT,
261261
);
262262
gitBranchIsCmd(args, (err, result) => {
263263
assert.ifError(err);
@@ -276,7 +276,7 @@ describe('git-branch-is', () => {
276276
TEST_REPO_PATH,
277277
'-C',
278278
'..',
279-
BRANCH_CURRENT
279+
BRANCH_CURRENT,
280280
);
281281
gitBranchIsCmd(args, (err, result) => {
282282
assert.ifError(err);
@@ -293,7 +293,7 @@ describe('git-branch-is', () => {
293293
// Note: Also tests that Commander interprets this as option argument
294294
'--git-dir=.git',
295295
'--git-dir=invalid',
296-
BRANCH_CURRENT
296+
BRANCH_CURRENT,
297297
);
298298
gitBranchIsCmd(args, (err, result) => {
299299
assert.ifError(err);
@@ -311,7 +311,7 @@ describe('git-branch-is', () => {
311311
SUBDIR_NAME,
312312
`--git-arg=${gitArg}`,
313313
`--git-path=${process.execPath}`,
314-
'surprise'
314+
'surprise',
315315
);
316316
gitBranchIsCmd(args, (err, result) => {
317317
assert.ifError(err);
@@ -328,7 +328,7 @@ describe('git-branch-is', () => {
328328
'-C',
329329
SUBDIR_NAME,
330330
`--git-dir=${path.join('..', '.git')}`,
331-
BRANCH_CURRENT
331+
BRANCH_CURRENT,
332332
);
333333
gitBranchIsCmd(args, (err, result) => {
334334
assert.ifError(err);
@@ -389,12 +389,12 @@ describe('git-branch-is', () => {
389389
const promise = gitBranchIsCmd(ARGS.concat(
390390
'-C',
391391
'invalid',
392-
BRANCH_CURRENT
392+
BRANCH_CURRENT,
393393
));
394394
assert(promise instanceof global.Promise);
395395
return promise.then(
396396
(result) => { throw new Error('expecting Error'); },
397-
(err) => { assert(err instanceof Error); }
397+
(err) => { assert(err instanceof Error); },
398398
);
399399
});
400400

@@ -425,7 +425,7 @@ describe('git-branch-is', () => {
425425
gitBranchIsCmd(ARGS.concat(BRANCH_CURRENT));
426426
},
427427
(err) => err instanceof TypeError
428-
&& /\bcallback\b/.test(err.message)
428+
&& /\bcallback\b/.test(err.message),
429429
);
430430
});
431431
});
@@ -439,7 +439,7 @@ describe('git-branch-is', () => {
439439
assertMatch(stdout, BRANCH_CURRENT_RE);
440440
assert.strictEqual(stderr, '');
441441
done();
442-
}
442+
},
443443
);
444444
});
445445

@@ -453,7 +453,7 @@ describe('git-branch-is', () => {
453453
assertMatch(stderr, /\binvalid\b/);
454454
assertMatch(stderr, BRANCH_CURRENT_RE);
455455
done();
456-
}
456+
},
457457
);
458458
});
459459

@@ -467,7 +467,7 @@ describe('git-branch-is', () => {
467467
assert.strictEqual(stdout, '');
468468
assertMatch(stderr, /\bargument/);
469469
done();
470-
}
470+
},
471471
);
472472
});
473473
});

test/git-branch-is.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const {
1919
BRANCH_NON_EXISTENT,
2020
BRANCH_SAME_COMMIT,
2121
SUBDIR_NAME,
22-
TEST_REPO_PATH
22+
TEST_REPO_PATH,
2323
} = constants;
2424

2525
describe('gitBranchIs', () => {
@@ -48,7 +48,7 @@ describe('gitBranchIs', () => {
4848
});
4949

5050
it('callback true for same branch name in subdir', (done) => {
51-
gitBranchIs(BRANCH_CURRENT, {cwd: SUBDIR_NAME}, (err, result) => {
51+
gitBranchIs(BRANCH_CURRENT, { cwd: SUBDIR_NAME }, (err, result) => {
5252
assert.ifError(err);
5353
assert.strictEqual(result, true);
5454
done();
@@ -90,7 +90,7 @@ describe('gitBranchIs', () => {
9090
it('can specify additional git arguments', (done) => {
9191
const options = {
9292
cwd: '..',
93-
gitArgs: ['-C', TEST_REPO_PATH]
93+
gitArgs: ['-C', TEST_REPO_PATH],
9494
};
9595
gitBranchIs(BRANCH_CURRENT, options, (err, result) => {
9696
assert.ifError(err);
@@ -100,7 +100,7 @@ describe('gitBranchIs', () => {
100100
});
101101

102102
it('null gitArgs is ignored', (done) => {
103-
gitBranchIs(BRANCH_CURRENT, {gitArgs: null}, (err, result) => {
103+
gitBranchIs(BRANCH_CURRENT, { gitArgs: null }, (err, result) => {
104104
assert.ifError(err);
105105
assert.strictEqual(result, true);
106106
done();
@@ -110,7 +110,7 @@ describe('gitBranchIs', () => {
110110
it('gitArgs takes precedence over gitDir', (done) => {
111111
const options = {
112112
gitArgs: ['--git-dir=.git'],
113-
gitDir: 'invalid'
113+
gitDir: 'invalid',
114114
};
115115
gitBranchIs(BRANCH_CURRENT, options, (err, result) => {
116116
assert.ifError(err);
@@ -122,7 +122,7 @@ describe('gitBranchIs', () => {
122122
it('can specify git executable and args', (done) => {
123123
const options = {
124124
gitArgs: [path.join('..', 'test-bin', 'echo-surprise.js')],
125-
gitPath: process.execPath
125+
gitPath: process.execPath,
126126
};
127127
gitBranchIs('surprise', options, (err, result) => {
128128
assert.ifError(err);
@@ -132,15 +132,15 @@ describe('gitBranchIs', () => {
132132
});
133133

134134
it('callback Error outside of git repo', (done) => {
135-
gitBranchIs(BRANCH_CURRENT, {cwd: '/'}, (err, result) => {
135+
gitBranchIs(BRANCH_CURRENT, { cwd: '/' }, (err, result) => {
136136
assert(err instanceof Error);
137137
assert(result === undefined || result === null);
138138
done();
139139
});
140140
});
141141

142142
it('callback Error if cwd doesn\'t exist', (done) => {
143-
gitBranchIs(BRANCH_CURRENT, {cwd: 'invalid'}, (err, result) => {
143+
gitBranchIs(BRANCH_CURRENT, { cwd: 'invalid' }, (err, result) => {
144144
assert(err instanceof Error);
145145
assert(result === undefined || result === null);
146146
done();
@@ -149,15 +149,15 @@ describe('gitBranchIs', () => {
149149

150150
it('callback Error if git is not executable', (done) => {
151151
const badGitPath = path.join(__dirname, '..', 'package.json');
152-
gitBranchIs(BRANCH_CURRENT, {gitPath: badGitPath}, (err, result) => {
152+
gitBranchIs(BRANCH_CURRENT, { gitPath: badGitPath }, (err, result) => {
153153
assert(err instanceof Error);
154154
assert(result === undefined || result === null);
155155
done();
156156
});
157157
});
158158

159159
it('callback Error if gitDir is not a git repo', (done) => {
160-
gitBranchIs(BRANCH_CURRENT, {gitDir: SUBDIR_NAME}, (err, result) => {
160+
gitBranchIs(BRANCH_CURRENT, { gitDir: SUBDIR_NAME }, (err, result) => {
161161
assert(err instanceof Error);
162162
assert(result === undefined || result === null);
163163
done();
@@ -168,7 +168,7 @@ describe('gitBranchIs', () => {
168168
it('gitDir is relative to cwd', (done) => {
169169
const options = {
170170
cwd: SUBDIR_NAME,
171-
gitDir: path.join('..', '.git')
171+
gitDir: path.join('..', '.git'),
172172
};
173173
gitBranchIs(BRANCH_CURRENT, options, (err, result) => {
174174
assert.ifError(err);
@@ -181,7 +181,7 @@ describe('gitBranchIs', () => {
181181
const options = {
182182
cwd: SUBDIR_NAME,
183183
gitArgs: [path.join('..', '..', 'test-bin', 'echo-surprise.js')],
184-
gitPath: path.relative(SUBDIR_NAME, process.execPath)
184+
gitPath: path.relative(SUBDIR_NAME, process.execPath),
185185
};
186186
gitBranchIs('surprise', options, (err, result) => {
187187
assert.ifError(err);
@@ -224,7 +224,7 @@ describe('gitBranchIs', () => {
224224
(err) => {
225225
assert(err instanceof TypeError);
226226
assertMatch(err.message, /\boptions\b/);
227-
}
227+
},
228228
);
229229
});
230230

@@ -250,7 +250,7 @@ describe('gitBranchIs', () => {
250250
(result) => { throw new Error('expecting rejection'); },
251251
(err) => {
252252
assert.strictEqual(err, true);
253-
}
253+
},
254254
);
255255
});
256256

@@ -261,7 +261,7 @@ describe('gitBranchIs', () => {
261261
assert(promise instanceof global.Promise);
262262
return promise.then(
263263
(result) => { throw new Error('expecting rejection'); },
264-
(err) => { assert.strictEqual(err, errTest); }
264+
(err) => { assert.strictEqual(err, errTest); },
265265
);
266266
});
267267

@@ -282,7 +282,7 @@ describe('gitBranchIs', () => {
282282
(err) => {
283283
assert(err instanceof TypeError);
284284
assertMatch(err.message, /\boptions\b/);
285-
}
285+
},
286286
);
287287
});
288288
});

0 commit comments

Comments
 (0)