Skip to content

Commit 6310bdb

Browse files
committed
Define RegExp's up top.
1 parent ae30205 commit 6310bdb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

build/build.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ const hyperquest = require('hyperzip')(require('hyperdirect'))
66
, path = require('path')
77
, cheerio = require('cheerio')
88
, encoding = 'utf8'
9+
, urlRegex = /^https?:\/\//
910
, nodeVersion = process.argv[2]
1011
, nodeVersionRegexString = '\\d+\\.\\d+\\.\\d+'
12+
, usageVersionRegex = RegExp('^' + nodeVersionRegexString + '$')
13+
, readmeVersionRegex =
14+
RegExp('(Node-core v)' + nodeVersionRegexString, 'g')
15+
1116
, readmePath = path.join(__dirname, '..', 'README.md')
1217
, files = require('./files')
1318
, testReplace = require('./test-replacements')
@@ -23,14 +28,14 @@ const hyperquest = require('hyperzip')(require('hyperdirect'))
2328
, docourroot = path.join(__dirname, '../doc')
2429

2530

26-
if (!RegExp('^' + nodeVersionRegexString + '$').test(nodeVersion)) {
31+
if (!usageVersionRegex.test(nodeVersion)) {
2732
console.error('Usage: build.js xx.yy.zz')
2833
return process.exit(1);
2934
}
3035

3136
// `inputLoc`: URL or local path.
3237
function processFile (inputLoc, out, replacements) {
33-
var file = /^https?:\/\//.test(inputLoc) ?
38+
var file = urlRegex.test(inputLoc) ?
3439
hyperquest(inputLoc) :
3540
fs.createReadStream(inputLoc, encoding)
3641

@@ -107,8 +112,5 @@ processFile(
107112
// Update Node version in README
108113

109114
processFile(readmePath, readmePath, [
110-
[
111-
RegExp('(Node-core v)' + nodeVersionRegexString, 'g')
112-
, "$1" + nodeVersion
113-
]
115+
[readmeVersionRegex, "$1" + nodeVersion]
114116
])

0 commit comments

Comments
 (0)