Skip to content

Commit 4de782f

Browse files
committed
v3.0.1
1 parent 55c9dcb commit 4de782f

File tree

9 files changed

+4099
-37
lines changed

9 files changed

+4099
-37
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ Flag | Effect
123123
`-B` | **`--void-backup`** Avoid temporary backing up file. Works async (independent of -A flag) and will speed up things but at one point data lives only in memory and you will lose the content if the process is abrupted. [boolean]
124124
`-b` | **`--keep-backup`** Keep a backup file of the original content. [boolean]
125125
`-m` | **`--output-match`** Output each match on a new line. Will not replace any content but you still need to provide a dummy value (like `_`) as replacement parameter. If search pattern does not contain matching groups the full match will be outputted. If search pattern does contain matching groups only matching groups will be outputted (same line with no delimiter). [boolean]
126-
`-T` | **`--trim-pipe`** Trim piped data before processing. If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be considered an empty string. [boolean]
126+
`-T` | **`--trim-pipe`** Trim piped data before processing. If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be become an empty string. [boolean]
127127
`-R` | **`--replacement-pipe`** Replacement will be piped in. You still need to provide a dummy value (like `_`) as replacement parameter. [boolean]
128-
`-j` | **`--replacement-js`** Treat replacement as javascript source code. The statement from the last expression will become the replacement string. Purposefully implemented the most insecure way possible to remove _any_ incentive to consider running code from an untrusted person - that be anyone that is not yourself. The full match will be available as a javascript variable named $0 while each captured group will be avaiable as $1, $2, $3, ... and so on. At some point the $ char _will_ give you a headache when used from the command line, so use €0, €1, €2 €3 ... instead. If the javascript source code references to the full match or a captured group the code will run once per match. Otherwise it will run once per file. The code has access to the following variables: `_fs` from node, `_globs` from npm, `_pipe` is the piped data into the command (null if no piped data), `_find` is the final pattern searched for. `_text` is the full text being searched (Corresponds to file contents or piped data).The following values are also available if working on a file (if data is being piped they are all set to an empty string): `_file` is the full path of the active file being searched (including full filename), `_path` is the full path without filename of the active file being searched, `_filename` is the full filename of the active file being searched, `_name` is the filename of the active file being searched with no extension, `_ext` is the extension of the filename including leading dot. [boolean]
128+
`-j` | **`--replacement-js`** Treat replacement as javascript source code. The statement from the last expression will become the replacement string. Purposefully implemented the most insecure way possible to remove _any_ incentive to consider running code from an untrusted person - that be anyone that is not yourself. The full match will be available as a javascript variable named $0 while each captured group will be avaiable as $1, $2, $3, ... and so on. At some point the $ char _will_ give you a headache when used from the command line, so use €0, €1, €2 €3 ... instead. If the javascript source code references to the full match or a captured group the code will run once per match. Otherwise it will run once per file. The code has access to the following variables: `_fs` from node, `_globs` from npm, `_pipe` is the piped data into the command (null if no piped data), `_find` is the final pattern searched for. `_text` is the full text being searched (= file contents or piped data). The following values are also available if working on a file (if data is being piped they are all set to an empty string): `_file` is the full path of the active file being searched (including full filename), `_path` is the full path without filename of the active file being searched, `_filename` is the full filename of the active file being searched, `_name` is the filename of the active file being searched with no extension, `_ext` is the extension of the filename including leading dot. [boolean]
129129
`-h` | **`--help`** Display help. [boolean]
130130
## Good to know
131131

build/ES5/rexreplace.cli.bundle.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7412,6 +7412,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
74127412
var MAX_LENGTH = 256;
74137413
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
74147414

7415+
// Max safe segment length for coercion.
7416+
var MAX_SAFE_COMPONENT_LENGTH = 16;
7417+
74157418
// The actual regexps go on exports.re
74167419
var re = exports.re = [];
74177420
var src = exports.src = [];
@@ -7520,6 +7523,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
75207523
var XRANGELOOSE = R++;
75217524
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$';
75227525

7526+
// Coercion.
7527+
// Extract anything that could conceivably be a part of a valid semver
7528+
var COERCE = R++;
7529+
src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])';
7530+
75237531
// Tilde ranges.
75247532
// Meaning is "reasonably at or greater than"
75257533
var LONETILDE = R++;
@@ -8515,6 +8523,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
85158523
r2 = new Range(r2, loose);
85168524
return r1.intersects(r2);
85178525
}
8526+
8527+
exports.coerce = coerce;
8528+
function coerce(version) {
8529+
if (version instanceof SemVer) return version;
8530+
8531+
if (typeof version !== 'string') return null;
8532+
8533+
var match = version.match(re[COERCE]);
8534+
8535+
if (match == null) return null;
8536+
8537+
return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
8538+
}
85188539
}, {}], 65: [function (require, module, exports) {
85198540
module.exports = function (blocking) {
85208541
[process.stdout, process.stderr].forEach(function (stream) {
@@ -14369,7 +14390,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1436914390
.boolean('I').describe('I', 'Void case insensitive search pattern.').alias('I', 'void-ignore-case').boolean('G').describe('G', 'Void global search (work only with first the match).').alias('G', 'void-global').boolean('M').describe('M', 'Void multiline search pattern. Makes ^ and $ match start/end of whole content rather than each line.').alias('M', 'void-multiline').boolean('u').describe('u', 'Treat pattern as a sequence of unicode code points.').alias('u', 'unicode').default('e', 'utf8').alias('e', 'encoding').describe('e', 'Encoding of files/piped data.').boolean('q').describe('q', "Only display errors (no other info)").alias('q', 'quiet').boolean('Q').describe('Q', "Never display errors or info").alias('Q', 'quiet-total').boolean('H').describe('H', "Halt on first error").alias('H', 'halt').default('H', false).boolean('d').describe('d', "Print debug info").alias('d', 'debug').boolean('€').describe('€', "Void having '€' as alias for '$' in pattern and replacement parameters").alias('€', 'void-euro').boolean('o').describe('o', 'Output the final result instead of saving to file. Will also output content even if no replacement has taken place.').alias('o', 'output')
1437014391
//.conflicts('o','O')
1437114392

14372-
.boolean('A').alias('A', 'void-async').describe('A', "Handle files in a synchronous flow. Good to limit memory usage when handling large files. " + '').boolean('B').describe('B', "Avoid temporary backing up file. Works async (independent of -A flag) and will speed up things but at one point data lives only in memory and you will lose the content if the process is abrupted.").alias('B', 'void-backup').boolean('b').describe('b', "Keep a backup file of the original content.").alias('b', 'keep-backup').boolean('m').describe('m', "Output each match on a new line. " + "Will not replace any content but you still need to provide a dummy value (like '_') as replacement parameter. " + "If search pattern does not contain matching groups the full match will be outputted. " + "If search pattern does contain matching groups only matching groups will be outputted (same line with no delimiter). " + "").alias('m', 'output-match').boolean('T').alias('T', 'trim-pipe').describe('T', "Trim piped data before processing. " + "If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be considered an empty string. " + '').boolean('R').alias('R', 'replacement-pipe').describe('R', "Replacement will be piped in. You still need to provide a dummy value (like '_') as replacement parameter." + '').boolean('j').alias('j', 'replacement-js').describe('j', "Treat replacement as javascript source code. " + "The statement from the last expression will become the replacement string. " + "Purposefully implemented the most insecure way possible to remove _any_ incentive to consider running code from an untrusted person - that be anyone that is not yourself. " + "The full match will be available as a javascript variable named $0 while each captured group will be avaiable as $1, $2, $3, ... and so on. " + "At some point the $ char _will_ give you a headache when used from the command line, so use \u20AC0, \u20AC1, \u20AC2 \u20AC3 ... instead. " + "If the javascript source code references to the full match or a captured group the code will run once per match. Otherwise it will run once per file. " + "The code has access to the following variables: " + "'_fs' from node, " + "'_globs' from npm, " + "'_pipe' is the piped data into the command (null if no piped data), " + "'_find' is the final pattern searched for. " + "'_text' is the full text being searched (Corresponds to file contents or piped data)." + "The following values are also available if working on a file (if data is being piped they are all set to an empty string): " + "'_file' is the full path of the active file being searched (including full filename), " + "'_path' is the full path without filename of the active file being searched, " + "'_filename' is the full filename of the active file being searched, " + "'_name' is the filename of the active file being searched with no extension, " + "'_ext' is the extension of the filename including leading dot. " + '')
14393+
.boolean('A').alias('A', 'void-async').describe('A', "Handle files in a synchronous flow. Good to limit memory usage when handling large files. " + '').boolean('B').describe('B', "Avoid temporary backing up file. Works async (independent of -A flag) and will speed up things but at one point data lives only in memory and you will lose the content if the process is abrupted.").alias('B', 'void-backup').boolean('b').describe('b', "Keep a backup file of the original content.").alias('b', 'keep-backup').boolean('m').describe('m', "Output each match on a new line. " + "Will not replace any content but you still need to provide a dummy value (like '_') as replacement parameter. " + "If search pattern does not contain matching groups the full match will be outputted. " + "If search pattern does contain matching groups only matching groups will be outputted (same line with no delimiter). " + "").alias('m', 'output-match').boolean('T').alias('T', 'trim-pipe').describe('T', "Trim piped data before processing. " + "If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be become an empty string. " + '').boolean('R').alias('R', 'replacement-pipe').describe('R', "Replacement will be piped in. You still need to provide a dummy value (like '_') as replacement parameter." + '').boolean('j').alias('j', 'replacement-js').describe('j', "Treat replacement as javascript source code. " + "The statement from the last expression will become the replacement string. " + "Purposefully implemented the most insecure way possible to remove _any_ incentive to consider running code from an untrusted person - that be anyone that is not yourself. " + "The full match will be available as a javascript variable named $0 while each captured group will be avaiable as $1, $2, $3, ... and so on. " + "At some point the $ char _will_ give you a headache when used from the command line, so use \u20AC0, \u20AC1, \u20AC2 \u20AC3 ... instead. " + "If the javascript source code references to the full match or a captured group the code will run once per match. Otherwise it will run once per file. " + "\nThe code has access to the following variables: " + "\n'_fs' from node, " + "\n'_globs' from npm, " + "\n'_pipe' is the piped data into the command (null if no piped data), " + "\n'_find' is the final pattern searched for. " + "\n'_text' is the full text being searched (= file contents or piped data). " + "\nThe following values are also available if working on a file (if data is being piped they are all set to an empty string): " + "\n'_file' is the full path of the active file being searched (including full filename), " + "\n'_path' is the full path without filename of the active file being searched, " + "\n'_filename' is the full filename of the active file being searched, " + "\n'_name' is the filename of the active file being searched with no extension, " + "\n'_ext' is the extension of the filename including leading dot. " + '')
1437314394

1437414395
/*
1437514396
.boolean('N')
@@ -14502,7 +14523,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1450214523
var path = require('path');
1450314524
var globs = require('globs');
1450414525

14505-
var version = '3.0.0';
14526+
var version = '3.0.1';
1450614527

1450714528
module.exports = function (config) {
1450814529
var _require2 = require('./output')(config),

build/ES5/rexreplace.core.bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3431,7 +3431,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
34313431
var path = require('path');
34323432
var globs = require('globs');
34333433

3434-
var version = '3.0.0';
3434+
var version = '3.0.1';
34353435

34363436
module.exports = function (config) {
34373437
var _require = require('./output')(config),

build/ES6/rexreplace.cli.bundle.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7880,6 +7880,9 @@ exports.SEMVER_SPEC_VERSION = '2.0.0';
78807880
var MAX_LENGTH = 256;
78817881
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
78827882

7883+
// Max safe segment length for coercion.
7884+
var MAX_SAFE_COMPONENT_LENGTH = 16;
7885+
78837886
// The actual regexps go on exports.re
78847887
var re = exports.re = [];
78857888
var src = exports.src = [];
@@ -8015,6 +8018,15 @@ src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
80158018
var XRANGELOOSE = R++;
80168019
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$';
80178020

8021+
// Coercion.
8022+
// Extract anything that could conceivably be a part of a valid semver
8023+
var COERCE = R++;
8024+
src[COERCE] = '(?:^|[^\\d])' +
8025+
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
8026+
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
8027+
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
8028+
'(?:$|[^\\d])';
8029+
80188030
// Tilde ranges.
80198031
// Meaning is "reasonably at or greater than"
80208032
var LONETILDE = R++;
@@ -9154,6 +9166,22 @@ function intersects(r1, r2, loose) {
91549166
return r1.intersects(r2)
91559167
}
91569168

9169+
exports.coerce = coerce;
9170+
function coerce(version) {
9171+
if (version instanceof SemVer)
9172+
return version;
9173+
9174+
if (typeof version !== 'string')
9175+
return null;
9176+
9177+
var match = version.match(re[COERCE]);
9178+
9179+
if (match == null)
9180+
return null;
9181+
9182+
return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
9183+
}
9184+
91579185
},{}],65:[function(require,module,exports){
91589186
module.exports = function (blocking) {
91599187
[process.stdout, process.stderr].forEach(function (stream) {
@@ -15284,7 +15312,7 @@ const yargs = require('yargs')
1528415312
.alias('T', 'trim-pipe')
1528515313
.describe('T',
1528615314
`Trim piped data before processing. `+
15287-
`If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be considered an empty string. `+
15315+
`If piped data only consists of chars that can be trimmed (new line, space, tabs...) it will be become an empty string. `+
1528815316
''
1528915317
)
1529015318

@@ -15304,18 +15332,18 @@ const yargs = require('yargs')
1530415332
`The full match will be available as a javascript variable named $0 while each captured group will be avaiable as $1, $2, $3, ... and so on. `+
1530515333
`At some point the $ char _will_ give you a headache when used from the command line, so use €0, €1, €2 €3 ... instead. `+
1530615334
`If the javascript source code references to the full match or a captured group the code will run once per match. Otherwise it will run once per file. `+
15307-
`The code has access to the following variables: `+
15308-
`'_fs' from node, `+
15309-
`'_globs' from npm, `+
15310-
`'_pipe' is the piped data into the command (null if no piped data), `+
15311-
`'_find' is the final pattern searched for. `+
15312-
`'_text' is the full text being searched (Corresponds to file contents or piped data).`+
15313-
`The following values are also available if working on a file (if data is being piped they are all set to an empty string): `+
15314-
`'_file' is the full path of the active file being searched (including full filename), `+
15315-
`'_path' is the full path without filename of the active file being searched, `+
15316-
`'_filename' is the full filename of the active file being searched, `+
15317-
`'_name' is the filename of the active file being searched with no extension, `+
15318-
`'_ext' is the extension of the filename including leading dot. `+
15335+
`\nThe code has access to the following variables: `+
15336+
`\n'_fs' from node, `+
15337+
`\n'_globs' from npm, `+
15338+
`\n'_pipe' is the piped data into the command (null if no piped data), `+
15339+
`\n'_find' is the final pattern searched for. `+
15340+
`\n'_text' is the full text being searched (= file contents or piped data). `+
15341+
`\nThe following values are also available if working on a file (if data is being piped they are all set to an empty string): `+
15342+
`\n'_file' is the full path of the active file being searched (including full filename), `+
15343+
`\n'_path' is the full path without filename of the active file being searched, `+
15344+
`\n'_filename' is the full filename of the active file being searched, `+
15345+
`\n'_name' is the filename of the active file being searched with no extension, `+
15346+
`\n'_ext' is the extension of the filename including leading dot. `+
1531915347
''
1532015348
)
1532115349

@@ -15476,7 +15504,7 @@ const fs = require('fs');
1547615504
const path = require('path');
1547715505
const globs = require('globs');
1547815506

15479-
const version = '3.0.0';
15507+
const version = '3.0.1';
1548015508

1548115509
module.exports = function(config){
1548215510

build/ES6/rexreplace.core.bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3665,7 +3665,7 @@ const fs = require('fs');
36653665
const path = require('path');
36663666
const globs = require('globs');
36673667

3668-
const version = '3.0.0';
3668+
const version = '3.0.1';
36693669

36703670
module.exports = function(config){
36713671

0 commit comments

Comments
 (0)