@@ -6,8 +6,13 @@ const hyperquest = require('hyperzip')(require('hyperdirect'))
66 , path = require ( 'path' )
77 , cheerio = require ( 'cheerio' )
88 , encoding = 'utf8'
9+ , urlRegex = / ^ h t t p s ? : \/ \/ /
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.
3237function processFile ( inputLoc , out , replacements ) {
33- var file = / ^ h t t p s ? : \/ \/ / . 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
109114processFile ( readmePath , readmePath , [
110- [
111- RegExp ( '(Node-core v)' + nodeVersionRegexString , 'g' )
112- , "$1" + nodeVersion
113- ]
115+ [ readmeVersionRegex , "$1" + nodeVersion ]
114116] )
0 commit comments