diff options
author | XhmikosR <xhmikosr@gmail.com> | 2017-12-16 15:00:38 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2018-01-11 19:48:46 +0300 |
commit | 80d0943b95984bfaf4997d2198d467876d294bd8 (patch) | |
tree | fa2eb4c869753b6e20c771a928da460587f38fdf /build/change-version.js | |
parent | 6d336502c7e26c4cc5b35f1d7a19c067b774cb1f (diff) |
Comply to the new rules.
Diffstat (limited to 'build/change-version.js')
-rwxr-xr-x | build/change-version.js | 32 |
1 files changed, 16 insertions, 16 deletions
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) => { |