Skip to content

Commit 8cde736

Browse files
authoredJun 22, 2019
Breaking: require node >= 8.0 & upgrade eslint-config-eslint (#34)
1 parent 3d99f99 commit 8cde736

10 files changed

+166
-157
lines changed
 

‎.eslintrc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
env:
22
node: true
33
extends: "eslint-config-eslint"
4+
rules:
5+
no-console: 0

‎.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
language: node_js
22
node_js:
3-
- "4"
4-
- "5"
5-
- "6"
6-
- "7"
3+
- "8"
4+
- "10"
5+
- "12"
76
sudo: false
87
script: "npm test"

‎bin/eslint-generate-prerelease.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Requirements
1414
//------------------------------------------------------------------------------
1515

16-
var ReleaseOps = require("../lib/release-ops");
16+
const ReleaseOps = require("../lib/release-ops");
1717

1818
//------------------------------------------------------------------------------
1919
// Execution
@@ -23,13 +23,13 @@ var ReleaseOps = require("../lib/release-ops");
2323
* Usage:
2424
* $ eslint-generate-prerelease beta
2525
*/
26-
var args = process.argv.slice(2),
26+
const args = process.argv.slice(2),
2727
prereleaseId = (args.length ? args[0] : null);
2828

2929
// there must be a prerelease ID
3030
if (!prereleaseId) {
3131
console.log("Missing prerelease identifier (alpha, beta, rc, etc.).");
32-
process.exit(1); // eslint-disable-line no-process-exit
32+
process.exit(1); // eslint-disable-line no-process-exit
3333
}
3434

3535
ReleaseOps.generateRelease(prereleaseId);

‎bin/eslint-generate-release.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Requirements
1414
//------------------------------------------------------------------------------
1515

16-
var ReleaseOps = require("../lib/release-ops");
16+
const ReleaseOps = require("../lib/release-ops");
1717

1818
//------------------------------------------------------------------------------
1919
// Execution

‎bin/eslint-publish-release.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Requirements
1414
//------------------------------------------------------------------------------
1515

16-
var ReleaseOps = require("../lib/release-ops");
16+
const ReleaseOps = require("../lib/release-ops");
1717

1818
//------------------------------------------------------------------------------
1919
// Execution

‎lib/release-ops.js

+67-63
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Requirements
1212
//------------------------------------------------------------------------------
1313

14-
var fs = require("fs"),
14+
const fs = require("fs"),
1515
path = require("path"),
1616
shelljs = require("shelljs"),
1717
semver = require("semver"),
@@ -33,7 +33,8 @@ var fs = require("fs"),
3333
* @private
3434
*/
3535
function getPackageInfo() {
36-
var filePath = path.join(process.cwd(), "package.json");
36+
const filePath = path.join(process.cwd(), "package.json");
37+
3738
return JSON.parse(fs.readFileSync(filePath, "utf8"));
3839
}
3940

@@ -48,7 +49,8 @@ function validateSetup() {
4849
ShellOps.exit(1);
4950
}
5051

51-
var pkg = getPackageInfo();
52+
const pkg = getPackageInfo();
53+
5254
if (!pkg.files || pkg.files.length === 0) {
5355
console.error("Missing 'files' property in package.json");
5456
ShellOps.exit(1);
@@ -58,7 +60,7 @@ function validateSetup() {
5860
if (!pkg.repository) {
5961
console.error("Missing 'repository' in package.json");
6062
ShellOps.exit(1);
61-
} else if (!/^[\w\-]+\/[\w\-]+$/.test(pkg.repository)) {
63+
} else if (!/^[\w-]+\/[\w-]+$/.test(pkg.repository)) {
6264
console.error("The 'repository' field must be in the format 'foo/bar' in package.json");
6365
ShellOps.exit(1);
6466
}
@@ -89,14 +91,14 @@ function validateEnvironment() {
8991
* @private
9092
*/
9193
function getPrereleaseVersion(currentVersion, prereleaseId, releaseType) {
92-
var ver = new semver.SemVer(currentVersion);
94+
const ver = new semver.SemVer(currentVersion);
9395

9496
// if it's already a prerelease version
9597
if (ver.prerelease.length) {
9698
return ver.inc("prerelease", prereleaseId).version;
97-
} else {
98-
return ver.inc("pre" + releaseType, prereleaseId).version;
9999
}
100+
return ver.inc(`pre${releaseType}`, prereleaseId).version;
101+
100102
}
101103

102104
/**
@@ -105,9 +107,9 @@ function getPrereleaseVersion(currentVersion, prereleaseId, releaseType) {
105107
* @private
106108
*/
107109
function getVersionTags() {
108-
var tags = ShellOps.execSilent("git tag").trim().split("\n");
110+
const tags = ShellOps.execSilent("git tag").trim().split("\n");
109111

110-
return tags.reduce(function(list, tag) {
112+
return tags.reduce((list, tag) => {
111113
if (semver.valid(tag)) {
112114
list.push(tag);
113115
}
@@ -122,11 +124,11 @@ function getVersionTags() {
122124
* @private
123125
*/
124126
function parseLogs(logs) {
125-
var regexp = /^\* ([0-9a-f]{40}) ((?:([a-z]+): ?)?.*) \((.*)\)/i,
127+
const regexp = /^\* ([0-9a-f]{40}) ((?:([a-z]+): ?)?.*) \((.*)\)/i,
126128
parsed = [];
127129

128-
logs.forEach(function(log) {
129-
var match = log.match(regexp);
130+
logs.forEach(log => {
131+
const match = log.match(regexp);
130132

131133
if (match) {
132134
parsed.push({
@@ -138,7 +140,7 @@ function parseLogs(logs) {
138140
body: ""
139141
});
140142
} else if (parsed.length) {
141-
parsed[parsed.length - 1].body += log + "\n";
143+
parsed[parsed.length - 1].body += `${log}\n`;
142144
}
143145
});
144146

@@ -152,32 +154,32 @@ function parseLogs(logs) {
152154
* @returns {Object[]} An array of parsed commit log messages.
153155
*/
154156
function excludeReverts(logs) {
155-
logs = logs.slice();
157+
const newLogs = logs.slice();
156158

157-
var revertRegex = /This reverts commit ([0-9a-f]{40})/,
158-
shaIndexMap = Object.create(null), // Map of commit shas to indices
159-
i, log, match, sha;
159+
const revertRegex = /This reverts commit ([0-9a-f]{40})/,
160+
shaIndexMap = Object.create(null); // Map of commit shas to indices
161+
let i, log, match, sha;
160162

161163
// iterate in reverse because revert commits have lower indices than the
162164
// commits they revert
163-
for (i = logs.length - 1; i >= 0; i--) {
164-
log = logs[i];
165+
for (i = newLogs.length - 1; i >= 0; i--) {
166+
log = newLogs[i];
165167
match = log.body.match(revertRegex);
166168

167169
if (match) {
168170
sha = match[1];
169171

170172
// only exclude this revert if we can find the commit it reverts
171173
if (typeof shaIndexMap[sha] !== "undefined") {
172-
logs[shaIndexMap[sha]] = null;
173-
logs[i] = null;
174+
newLogs[shaIndexMap[sha]] = null;
175+
newLogs[i] = null;
174176
}
175177
} else {
176178
shaIndexMap[log.sha] = i;
177179
}
178180
}
179181

180-
return logs.filter(Boolean);
182+
return newLogs.filter(Boolean);
181183
}
182184

183185
/**
@@ -191,9 +193,9 @@ function excludeReverts(logs) {
191193
*/
192194
function calculateReleaseFromGitLogs(currentVersion, logs, prereleaseId) {
193195

194-
logs = excludeReverts(parseLogs(logs));
196+
const excludedLogs = excludeReverts(parseLogs(logs));
195197

196-
var changelog = {},
198+
const changelog = {},
197199
repository = getPackageInfo().repository;
198200

199201
/**
@@ -202,19 +204,20 @@ function calculateReleaseFromGitLogs(currentVersion, logs, prereleaseId) {
202204
* @returns {string} A line for a changelog with a link to the GitHub commit
203205
*/
204206
function generateChangelogLine(log) {
205-
return log.raw.replace(/^\* ([0-9a-f]{40})/, function(_, hash) {
206-
return "* [`" + hash.slice(0, 7) + "`](https://github.com/" + repository + "/commit/" + hash + ")";
207-
});
207+
return log.raw.replace(
208+
/^\* ([0-9a-f]{40})/,
209+
(_, hash) => `* [\`${hash.slice(0, 7)}\`](https://github.com/${repository}/commit/${hash})`
210+
);
208211
}
209-
var releaseInfo = {
212+
const releaseInfo = {
210213
version: currentVersion,
211214
type: "",
212-
changelog: changelog,
213-
rawChangelog: logs.map(generateChangelogLine).join("\n")
215+
changelog,
216+
rawChangelog: excludedLogs.map(generateChangelogLine).join("\n")
214217
};
215218

216219
// arrange change types into categories
217-
logs.forEach(function(log) {
220+
excludedLogs.forEach(log => {
218221

219222
// exclude untagged (e.g. revert) commits from version calculation
220223
if (!log.flag) {
@@ -238,9 +241,9 @@ function calculateReleaseFromGitLogs(currentVersion, logs, prereleaseId) {
238241

239242
// increment version from current version
240243
releaseInfo.version = (
241-
prereleaseId ?
242-
getPrereleaseVersion(currentVersion, prereleaseId, releaseInfo.type) :
243-
semver.inc(currentVersion, releaseInfo.type)
244+
prereleaseId
245+
? getPrereleaseVersion(currentVersion, prereleaseId, releaseInfo.type)
246+
: semver.inc(currentVersion, releaseInfo.type)
244247
);
245248

246249
return releaseInfo;
@@ -255,14 +258,15 @@ function calculateReleaseFromGitLogs(currentVersion, logs, prereleaseId) {
255258
function calculateReleaseInfo(prereleaseId) {
256259

257260
// get most recent tag
258-
var pkg = getPackageInfo(),
261+
const pkg = getPackageInfo(),
259262
tags = getVersionTags(),
260263
lastTag = tags[tags.length - 1],
261-
commitRange = lastTag ? lastTag + "..HEAD" : "";
264+
commitRange = lastTag ? `${lastTag}..HEAD` : "";
262265

263266
// get log statements
264-
var logs = ShellOps.execSilent("git log --no-merges --pretty=format:\"* %H %s (%an)%n%b\" " + commitRange).split(/\n/g);
265-
var releaseInfo = calculateReleaseFromGitLogs(pkg.version, logs, prereleaseId);
267+
const logs = ShellOps.execSilent(`git log --no-merges --pretty=format:"* %H %s (%an)%n%b" ${commitRange}`).split(/\n/g);
268+
const releaseInfo = calculateReleaseFromGitLogs(pkg.version, logs, prereleaseId);
269+
266270
releaseInfo.repository = pkg.repository;
267271
return releaseInfo;
268272
}
@@ -277,14 +281,14 @@ function calculateReleaseInfo(prereleaseId) {
277281
function writeChangelog(releaseInfo) {
278282

279283
// get most recent two tags
280-
var now = new Date(),
284+
const now = new Date(),
281285
timestamp = dateformat(now, "mmmm d, yyyy");
282286

283287
// output header
284-
("v" + releaseInfo.version + " - " + timestamp + "\n").to("CHANGELOG.tmp");
288+
(`v${releaseInfo.version} - ${timestamp}\n`).to("CHANGELOG.tmp");
285289

286290
// output changelog
287-
("\n" + releaseInfo.rawChangelog + "\n").toEnd("CHANGELOG.tmp");
291+
(`\n${releaseInfo.rawChangelog}\n`).toEnd("CHANGELOG.tmp");
288292

289293
// ensure there's a CHANGELOG.md file
290294
if (!shelljs.test("-f", "CHANGELOG.md")) {
@@ -312,7 +316,7 @@ function generateRelease(prereleaseId) {
312316
ShellOps.execSilent("npm test");
313317

314318
console.log("Calculating changes for release");
315-
var releaseInfo = calculateReleaseInfo(prereleaseId);
319+
const releaseInfo = calculateReleaseInfo(prereleaseId);
316320

317321
console.log("Release is %s", releaseInfo.version);
318322

@@ -321,17 +325,15 @@ function generateRelease(prereleaseId) {
321325

322326
console.log("Committing to git");
323327
ShellOps.exec("git add CHANGELOG.md");
324-
ShellOps.exec("git commit -m \"Build: changelog update for " + releaseInfo.version + "\"");
328+
ShellOps.exec(`git commit -m "Build: changelog update for ${releaseInfo.version}"`);
325329

326330
console.log("Generating %s", releaseInfo.version);
327-
ShellOps.execSilent("npm version " + releaseInfo.version);
331+
ShellOps.execSilent(`npm version ${releaseInfo.version}`);
328332

329333
console.log("Fixing line endings");
330-
getPackageInfo().files.filter(function(dirPath) {
331-
return fs.lstatSync(dirPath).isDirectory();
332-
}).forEach(function(filePath) {
334+
getPackageInfo().files.filter(dirPath => fs.lstatSync(dirPath).isDirectory()).forEach(filePath => {
333335
if (fs.existsSync(filePath)) {
334-
ShellOps.execSilent("linefix " + filePath);
336+
ShellOps.execSilent(`linefix ${filePath}`);
335337
}
336338
});
337339

@@ -346,18 +348,18 @@ function generateRelease(prereleaseId) {
346348
*/
347349
function publishReleaseToGitHub(releaseInfo) {
348350

349-
var repoParts = releaseInfo.repository.split("/"),
351+
const repoParts = releaseInfo.repository.split("/"),
350352
gh = new GitHub({ token: process.env.ESLINT_GITHUB_TOKEN }),
351353
repo = gh.getRepo(repoParts[0], repoParts[1]),
352-
tag = "v" + releaseInfo.version;
354+
tag = `v${releaseInfo.version}`;
353355

354356
return repo.createRelease({
355-
tag_name: tag,
357+
tag_name: tag, // eslint-disable-line camelcase
356358
body: releaseInfo.rawChangelog,
357359
prerelease: !!semver.prerelease(releaseInfo.version)
358-
}).then(function() {
360+
}).then(() => {
359361
console.log("Posted release notes to GitHub");
360-
}).catch(function(ex) {
362+
}).catch(ex => {
361363
console.error("Could not post release notes to GitHub");
362364
if (ex.message) {
363365
console.error(ex.message);
@@ -373,9 +375,10 @@ function publishReleaseToGitHub(releaseInfo) {
373375
function publishRelease() {
374376
validateSetup();
375377
validateEnvironment();
376-
var releaseInfo = JSON.parse(fs.readFileSync(".eslint-release-info.json", "utf8"));
378+
const releaseInfo = JSON.parse(fs.readFileSync(".eslint-release-info.json", "utf8"));
379+
380+
let oldNpmrcContents;
377381

378-
var oldNpmrcContents;
379382
if (fs.existsSync(".npmrc")) {
380383
oldNpmrcContents = fs.readFileSync(".npmrc", "utf8");
381384
} else {
@@ -389,13 +392,14 @@ function publishRelease() {
389392
// if there's a prerelease ID, publish under "next" tag
390393
console.log("Publishing to npm");
391394

392-
var command = "npm publish";
395+
let command = "npm publish";
396+
393397
if (semver.prerelease(releaseInfo.version)) {
394398
command += " --tag next";
395399
}
396400

397401
if (process.env.NPM_OTP && /^\d+$/.test(process.env.NPM_OTP)) {
398-
command += " --otp=" + process.env.NPM_OTP;
402+
command += ` --otp=${process.env.NPM_OTP}`;
399403
}
400404

401405
ShellOps.exec(command);
@@ -419,10 +423,10 @@ function publishRelease() {
419423
//------------------------------------------------------------------------------
420424

421425
module.exports = {
422-
getPrereleaseVersion: getPrereleaseVersion,
423-
generateRelease: generateRelease,
424-
publishRelease: publishRelease,
425-
calculateReleaseInfo: calculateReleaseInfo,
426-
calculateReleaseFromGitLogs: calculateReleaseFromGitLogs,
427-
writeChangelog: writeChangelog
426+
getPrereleaseVersion,
427+
generateRelease,
428+
publishRelease,
429+
calculateReleaseInfo,
430+
calculateReleaseFromGitLogs,
431+
writeChangelog
428432
};

‎lib/shell-ops.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Requirements
1212
//------------------------------------------------------------------------------
1313

14-
var path = require("path"),
14+
const path = require("path"),
1515
childProcess = require("child_process");
1616

1717
//------------------------------------------------------------------------------
@@ -28,15 +28,11 @@ module.exports = {
2828
* @param {Object} [defaultEnv] The default environment object (mostly used for testing).
2929
* @returns {Object} a modified environment object.
3030
*/
31-
getModifiedEnv: function(platform, defaultEnv) {
32-
33-
platform = platform || process.platform;
34-
defaultEnv = defaultEnv || process.env;
35-
36-
var env = {},
31+
getModifiedEnv(platform = process.platform, defaultEnv = process.env) {
32+
const env = {},
3733
pathSeparator = platform === "win32" ? ";" : ":";
3834

39-
Object.keys(defaultEnv).forEach(function(key) {
35+
Object.keys(defaultEnv).forEach(key => {
4036
env[key] = defaultEnv[key];
4137
});
4238

@@ -53,7 +49,7 @@ module.exports = {
5349
* @returns {string} The result of the executed command.
5450
* @private
5551
*/
56-
execSilent: function(cmd) {
52+
execSilent(cmd) {
5753
try {
5854
return childProcess.execSync(cmd, {
5955
cwd: process.cwd(),
@@ -73,9 +69,10 @@ module.exports = {
7369
* @throws {Error} If the command exits with a nonzero exit code.
7470
* @private
7571
*/
76-
exec: function(cmd) {
77-
console.log("+ " + cmd.replace(/--otp=\d+/g, "--otp=(redacted)"));
78-
var result = this.execSilent(cmd);
72+
exec(cmd) {
73+
console.log(`+ ${cmd.replace(/--otp=\d+/g, "--otp=(redacted)")}`);
74+
const result = this.execSilent(cmd);
75+
7976
console.log(result);
8077
},
8178

@@ -85,7 +82,7 @@ module.exports = {
8582
* @param {int} code The exit code.
8683
* @returns {void}
8784
*/
88-
exit: function(code) {
85+
exit(code) {
8986
process.exit(code); // eslint-disable-line no-process-exit
9087
}
9188
};

‎package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "ESLint Release Tools",
55
"main": "./lib/release-ops",
66
"engines": {
7-
"node": ">=0.12"
7+
"node": ">=8.0.0"
88
},
99
"bin": {
1010
"eslint-generate-release": "./bin/eslint-generate-release.js",
@@ -38,18 +38,19 @@
3838
},
3939
"homepage": "https://github.com/eslint/eslint-release#readme",
4040
"devDependencies": {
41-
"chai": "^3.4.1",
42-
"eslint": "2.4.0",
43-
"eslint-config-eslint": "^3.0.0",
44-
"leche": "^2.1.1",
45-
"mocha": "^2.3.4",
41+
"chai": "^4.2.0",
42+
"eslint": "^5.16.0",
43+
"eslint-config-eslint": "^5.0.1",
44+
"eslint-plugin-node": "^9.1.0",
45+
"leche": "^2.3.0",
46+
"mocha": "^6.1.4",
4647
"sinon": "^1.17.2"
4748
},
4849
"dependencies": {
49-
"dateformat": "^1.0.12",
50+
"dateformat": "^3.0.3",
5051
"github-api": "2.3.0",
5152
"linefix": "^0.1.1",
52-
"semver": "^5.1.0",
53-
"shelljs": "^0.5.3"
53+
"semver": "^6.1.1",
54+
"shelljs": "^0.8.3"
5455
}
5556
}

‎tests/lib/release-ops.js

+30-29
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
// Requirements
1212
//------------------------------------------------------------------------------
1313

14-
var assert = require("chai").assert,
14+
const assert = require("chai").assert,
1515
leche = require("leche"),
1616
ReleaseOps = require("../../lib/release-ops");
1717

1818
//------------------------------------------------------------------------------
1919
// Tests
2020
//------------------------------------------------------------------------------
2121

22-
describe("ReleaseOps", function() {
22+
describe("ReleaseOps", () => {
2323

24-
describe("getPrereleaseVersion()", function() {
24+
describe("getPrereleaseVersion()", () => {
2525

2626
leche.withData([
2727
["1.0.0", "alpha", "major", "2.0.0-alpha.0"],
@@ -34,28 +34,29 @@ describe("ReleaseOps", function() {
3434

3535
["2.0.0-alpha.1", "beta", "patch", "2.0.0-beta.0"]
3636

37-
], function(version, prereleaseId, releaseType, expected) {
37+
], (version, prereleaseId, releaseType, expected) => {
3838

39-
it("should return the correct next version", function() {
40-
var result = ReleaseOps.getPrereleaseVersion(version, prereleaseId, releaseType);
41-
assert.equal(result, expected);
39+
it("should return the correct next version", () => {
40+
const result = ReleaseOps.getPrereleaseVersion(version, prereleaseId, releaseType);
41+
42+
assert.strictEqual(result, expected);
4243
});
4344

4445
});
4546

4647
});
4748

48-
describe("calculateReleaseFromGitLogs()", function() {
49+
describe("calculateReleaseFromGitLogs()", () => {
4950

50-
it("should create a patch release when only bug fixes are present", function() {
51-
var logs = [
51+
it("should create a patch release when only bug fixes are present", () => {
52+
const logs = [
5253
"* 5b4812a956935358bf6e48f4d75a9bc998b3fe41 Fix: Something (Foo Bar)",
5354
"* 00a3526f3a6560e4f91d390725b9a70f5d974f89 Docs: Something else (foobar)",
5455
"* 24b2fdb310b89d7aad134df7e8863a5e055ac63f Fix: Something else (Foo B. Baz)"
5556
],
5657
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);
5758

58-
assert.deepEqual(releaseInfo, {
59+
assert.deepStrictEqual(releaseInfo, {
5960
version: "1.0.1",
6061
type: "patch",
6162
changelog: {
@@ -75,16 +76,16 @@ describe("ReleaseOps", function() {
7576
});
7677
});
7778

78-
it("should create a minor release when enhancements are present", function() {
79-
var logs = [
79+
it("should create a minor release when enhancements are present", () => {
80+
const logs = [
8081
"* 34d6f550b2c87e61a70cb201abd3eadebb370453 Fix: Something (Author Name)",
8182
"* 5c5c361cc338d284cac6d170ab7e105e213e1307 Docs: Something else (authorname)",
8283
"* bcdc618488d12184e32a7ba170b443450c3e9e48 Fix: Something else (First Last)",
8384
"* 7e4ffad5c91e4f8a99a95955ec65c5dbe9ae1758 Update: Foo (dotstar)"
8485
],
8586
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);
8687

87-
assert.deepEqual(releaseInfo, {
88+
assert.deepStrictEqual(releaseInfo, {
8889
version: "1.1.0",
8990
type: "minor",
9091
changelog: {
@@ -108,8 +109,8 @@ describe("ReleaseOps", function() {
108109
});
109110
});
110111

111-
it("should create a major release when breaking changes are present", function() {
112-
var logs = [
112+
it("should create a major release when breaking changes are present", () => {
113+
const logs = [
113114
"* 34d6f550b2c87e61a70cb201abd3eadebb370453 Fix: Something (githubhandle)",
114115
"* 5c5c361cc338d284cac6d170ab7e105e213e1307 Docs: Something else (Committer Name)",
115116
"* bcdc618488d12184e32a7ba170b443450c3e9e48 Fix: Something else (Abc D. Efg)",
@@ -118,7 +119,7 @@ describe("ReleaseOps", function() {
118119
],
119120
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);
120121

121-
assert.deepEqual(releaseInfo, {
122+
assert.deepStrictEqual(releaseInfo, {
122123
version: "2.0.0",
123124
type: "major",
124125
changelog: {
@@ -146,8 +147,8 @@ describe("ReleaseOps", function() {
146147
});
147148
});
148149

149-
it("should disregard reverted commits", function() {
150-
var logs = [
150+
it("should disregard reverted commits", () => {
151+
const logs = [
151152
"* 34d6f550b2c87e61a70cb201abd3eadebb370453 Docs: Update something in the docs (githubhandle)",
152153
"This is the body.",
153154
"It has multiple lines.",
@@ -166,7 +167,7 @@ describe("ReleaseOps", function() {
166167
],
167168
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs);
168169

169-
assert.deepEqual(releaseInfo, {
170+
assert.deepStrictEqual(releaseInfo, {
170171
version: "1.0.1",
171172
type: "patch",
172173
changelog: {
@@ -185,8 +186,8 @@ describe("ReleaseOps", function() {
185186
});
186187
});
187188

188-
it("should create a prerelease when passed a prereleaseId", function() {
189-
var logs = [
189+
it("should create a prerelease when passed a prereleaseId", () => {
190+
const logs = [
190191
"* fbe463916e0b49bc55f37363bf577ee20e0b3da6 Fix: Something (githubhandle)",
191192
"* 7de216285f4d2e96508e6faefd9d8357baaaaec0 Docs: Something else (Committer Name)",
192193
"* cd06fd502d106d10821227fd2d2ff77f7332c100 Fix: Something else (Abc D. Efg)",
@@ -195,7 +196,7 @@ describe("ReleaseOps", function() {
195196
],
196197
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("1.0.0", logs, "alpha");
197198

198-
assert.deepEqual(releaseInfo, {
199+
assert.deepStrictEqual(releaseInfo, {
199200
version: "2.0.0-alpha.0",
200201
type: "major",
201202
changelog: {
@@ -223,15 +224,15 @@ describe("ReleaseOps", function() {
223224
});
224225
});
225226

226-
it("should create a prerelease when passed a prereleaseId and prerelease version", function() {
227-
var logs = [
227+
it("should create a prerelease when passed a prereleaseId and prerelease version", () => {
228+
const logs = [
228229
"* eda81fc28943d51377851295c5c09682496fb9ac Fix: Something (githubhandle)",
229230
"* 0c07d6ac037076557e34d569cd0290e529b3318a Docs: Something else (Committer Name)",
230231
"* 196d32dbfb7cb37b886e7c4ba0adff499c6b26ac Fix: Something else (Abc D. Efg)"
231232
],
232233
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("2.0.0-alpha.0", logs, "alpha");
233234

234-
assert.deepEqual(releaseInfo, {
235+
assert.deepStrictEqual(releaseInfo, {
235236
version: "2.0.0-alpha.1",
236237
type: "patch",
237238
changelog: {
@@ -251,15 +252,15 @@ describe("ReleaseOps", function() {
251252
});
252253
});
253254

254-
it("should gracefully handle unformatted commit messages", function() {
255-
var logs = [
255+
it("should gracefully handle unformatted commit messages", () => {
256+
const logs = [
256257
"* 70222e95932d3a391ac5717252e13b478d686ba9 0.4.0-alpha.4 (Nicholas C. Zakas)",
257258
"* d52a55e0572fbef1b702abfeefab9f53ff36d121 Build: package.json and changelog update for 0.4.0-alpha.4 (Nicholas C. Zakas)",
258259
"* 1934e59323448afd864acc1db712ef8ef730af1a Fix: Changelog output (Nicholas C. Zakas)"
259260
],
260261
releaseInfo = ReleaseOps.calculateReleaseFromGitLogs("0.4.0-alpha.4", logs, "alpha");
261262

262-
assert.deepEqual(releaseInfo, {
263+
assert.deepStrictEqual(releaseInfo, {
263264
version: "0.4.0-alpha.5",
264265
type: "patch",
265266
changelog: {

‎tests/lib/shell-ops.js

+39-34
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Requirements
1212
//------------------------------------------------------------------------------
1313

14-
var assert = require("chai").assert,
14+
const assert = require("chai").assert,
1515
sinon = require("sinon"),
1616
path = require("path"),
1717
leche = require("leche"),
@@ -21,49 +21,51 @@ var assert = require("chai").assert,
2121
// Tests
2222
//------------------------------------------------------------------------------
2323

24-
describe("ShellOps", function() {
24+
describe("ShellOps", () => {
2525

26-
var PATH = process.env.PATH,
26+
const PATH = process.env.PATH,
2727
NODE_MODULES_PATH = path.resolve("./node_modules/.bin");
2828

29-
describe("getModifiedEnv()", function() {
29+
describe("getModifiedEnv()", () => {
3030

31-
it("should modify path correctly when on Windows", function() {
32-
var env = ShellOps.getModifiedEnv("win32");
33-
assert.equal(env.PATH, NODE_MODULES_PATH + ";" + PATH);
31+
it("should modify path correctly when on Windows", () => {
32+
const env = ShellOps.getModifiedEnv("win32");
33+
34+
assert.strictEqual(env.PATH, `${NODE_MODULES_PATH};${PATH}`);
3435
});
3536

3637
leche.withData([
3738
"darwin",
3839
"freebsd",
3940
"linux",
4041
"sunos"
41-
], function(platform) {
42-
it("should modify path correctly when on Unix OS", function() {
43-
var env = ShellOps.getModifiedEnv(platform);
44-
assert.equal(env.PATH, NODE_MODULES_PATH + ":" + PATH);
42+
], platform => {
43+
it("should modify path correctly when on Unix OS", () => {
44+
const env = ShellOps.getModifiedEnv(platform);
45+
46+
assert.strictEqual(env.PATH, `${NODE_MODULES_PATH}:${PATH}`);
4547
});
4648
});
4749

4850
});
4951

50-
describe("execSilent()", function() {
52+
describe("execSilent()", () => {
5153

52-
var childProcess = require("child_process");
54+
const childProcess = require("child_process");
5355

54-
var CMD = "foo bar baz",
55-
ENV = ShellOps.getModifiedEnv(),
56-
sandbox;
56+
const CMD = "foo bar baz",
57+
ENV = ShellOps.getModifiedEnv();
58+
let sandbox;
5759

58-
beforeEach(function() {
60+
beforeEach(() => {
5961
sandbox = sinon.sandbox.create();
6062
});
6163

62-
afterEach(function() {
64+
afterEach(() => {
6365
sandbox.verifyAndRestore();
6466
});
6567

66-
it("should call execSync with cwd and modified environment", function() {
68+
it("should call execSync with cwd and modified environment", () => {
6769

6870
sandbox.mock(childProcess)
6971
.expects("execSync")
@@ -76,17 +78,19 @@ describe("ShellOps", function() {
7678
ShellOps.execSilent(CMD);
7779
});
7880

79-
it("should call execSync and pass through the return value", function() {
81+
it("should call execSync and pass through the return value", () => {
8082

8183
sandbox.stub(childProcess, "execSync").returns("hi");
8284

83-
var result = ShellOps.execSilent(CMD);
84-
assert.equal(result, "hi");
85+
const result = ShellOps.execSilent(CMD);
86+
87+
assert.strictEqual(result, "hi");
8588
});
8689

87-
it("should call exit with an exit code when execSync throws an error", function() {
90+
it("should call exit with an exit code when execSync throws an error", () => {
91+
92+
const err = new Error("Boo!");
8893

89-
var err = new Error("Boo!");
9094
err.output = [null, "Hi"];
9195
err.status = 2;
9296

@@ -97,23 +101,23 @@ describe("ShellOps", function() {
97101

98102
});
99103

100-
describe("exec()", function() {
104+
describe("exec()", () => {
101105

102-
var childProcess = require("child_process");
106+
const childProcess = require("child_process");
103107

104-
var CMD = "foo bar baz",
105-
ENV = ShellOps.getModifiedEnv(),
106-
sandbox;
108+
const CMD = "foo bar baz",
109+
ENV = ShellOps.getModifiedEnv();
110+
let sandbox;
107111

108-
beforeEach(function() {
112+
beforeEach(() => {
109113
sandbox = sinon.sandbox.create();
110114
});
111115

112-
afterEach(function() {
116+
afterEach(() => {
113117
sandbox.verifyAndRestore();
114118
});
115119

116-
it("should call execSync with cwd and modified environment", function() {
120+
it("should call execSync with cwd and modified environment", () => {
117121

118122
sandbox.mock(childProcess)
119123
.expects("execSync")
@@ -126,9 +130,10 @@ describe("ShellOps", function() {
126130
ShellOps.exec(CMD);
127131
});
128132

129-
it("should exit with an exit code when execSync throws an error", function() {
133+
it("should exit with an exit code when execSync throws an error", () => {
134+
135+
const err = new Error("Boo!");
130136

131-
var err = new Error("Boo!");
132137
err.output = [null, "Hi"];
133138
err.status = 2;
134139

0 commit comments

Comments
 (0)
Please sign in to comment.