From 80d0943b95984bfaf4997d2198d467876d294bd8 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 16 Dec 2017 14:00:38 +0200 Subject: Comply to the new rules. --- build/change-version.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'build/change-version.js') diff --git a/build/change-version.js b/build/change-version.js index ab4579072b..dc0b0c5dfd 100755 --- a/build/change-version.js +++ b/build/change-version.js @@ -18,8 +18,13 @@ const sh = require('shelljs') sh.config.fatal = true // Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37 -RegExp.quote = (string) => string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&') -RegExp.quoteReplacement = (string) => string.replace(/[$]/g, '$$') +function regExpQuote(string) { + return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&') +} + +function regExpQuoteReplacement(string) { + return string.replace(/[$]/g, '$$') +} const DRY_RUN = false @@ -39,13 +44,9 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) { process.nextTick(errback, err) return } - if (stats.isSymbolicLink()) { - return - } - else if (stats.isDirectory()) { + if (stats.isDirectory()) { process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback) - } - else if (stats.isFile()) { + } else if (stats.isFile()) { process.nextTick(fileCallback, filepath) } }) @@ -54,18 +55,17 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) { } function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { - original = new RegExp(RegExp.quote(original), 'g') - replacement = RegExp.quoteReplacement(replacement) - const updateFile = !DRY_RUN ? (filepath) => { + original = new RegExp(regExpQuote(original), 'g') + replacement = regExpQuoteReplacement(replacement) + const updateFile = DRY_RUN ? (filepath) => { if (allowedExtensions.has(path.parse(filepath).ext)) { - sh.sed('-i', original, replacement, filepath) + console.log(`FILE: ${filepath}`) + } else { + console.log(`EXCLUDED:${filepath}`) } } : (filepath) => { if (allowedExtensions.has(path.parse(filepath).ext)) { - console.log(`FILE: ${filepath}`) - } - else { - console.log(`EXCLUDED:${filepath}`) + sh.sed('-i', original, replacement, filepath) } } walkAsync(directory, excludedDirectories, updateFile, (err) => { -- cgit v1.2.3