Skip to content

Commit

Permalink
Fix #24
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrw committed Jan 2, 2020
1 parent dbcf1bf commit e64f8dd
Show file tree
Hide file tree
Showing 8 changed files with 461 additions and 1,540 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
language: node_js
node_js:
#- "node"
- "node"
- "12"
- "11"
- "10"
- "9"
- "8"
#- "7" 7 cant build google closure (but should be OK as long as 6 is OK to run rexreplace)
- "6"

install: npm install
install: yarn install --frozen-lockfile

script:
- npm run test-format # is formatting OK
- npm run test-cli # is provided build OK
- npm test # is provided source OK
- yarn test-format # is formatting OK
- yarn test-cli # is provided build OK
- yarn test # is provided source OK


before_install:
Expand Down
1 change: 1 addition & 0 deletions bin/ES6/cli.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
// CLI interface for rexreplace
import * as rexreplace from './engine';
let pattern, replacement;
// To avoid problems with patterns or replacements starting with '-' the two first arguments can not contain flags and are removed before yargs does it magic - but we still need to handle -version and -help
Expand Down
6 changes: 4 additions & 2 deletions bin/ES6/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function engine(config = { engine: 'V8' }) {
}
if (config.outputMatch) {
step('Output match');
if ('6' > process.versions.node) {
if (parseInt(process.versions.node) < 6) {
return die('outputMatch is only supported in node 6+');
}
return function () {
Expand All @@ -181,7 +181,9 @@ export function engine(config = { engine: 'V8' }) {
}
// If captured groups then run dynamicly
//console.log(process);
if (config.replacementJs && /\$\d/.test(config.replacement) && process.versions.node < '6') {
if (config.replacementJs &&
/\$\d/.test(config.replacement) &&
parseInt(process.versions.node) < 6) {
return die('Captured groups for javascript replacement is only supported in node 6+');
}
step(config.replacement);
Expand Down
6 changes: 4 additions & 2 deletions bin/rexreplace.cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
}
if (config.outputMatch) {
step('Output match');
if ('6' > process.versions.node) {
if (parseInt(process.versions.node) < 6) {
return die('outputMatch is only supported in node 6+');
}
return function () {
Expand All @@ -253,7 +253,9 @@
}
// If captured groups then run dynamicly
//console.log(process);
if (config.replacementJs && /\$\d/.test(config.replacement) && process.versions.node < '6') {
if (config.replacementJs &&
/\$\d/.test(config.replacement) &&
parseInt(process.versions.node) < 6) {
return die('Captured groups for javascript replacement is only supported in node 6+');
}
step(config.replacement);
Expand Down
6 changes: 4 additions & 2 deletions bin/rexreplace.cli.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
}
if (config.outputMatch) {
step('Output match');
if ('6' > process.versions.node) {
if (parseInt(process.versions.node) < 6) {
return die('outputMatch is only supported in node 6+');
}
return function () {
Expand All @@ -253,7 +253,9 @@
}
// If captured groups then run dynamicly
//console.log(process);
if (config.replacementJs && /\$\d/.test(config.replacement) && process.versions.node < '6') {
if (config.replacementJs &&
/\$\d/.test(config.replacement) &&
parseInt(process.versions.node) < 6) {
return die('Captured groups for javascript replacement is only supported in node 6+');
}
step(config.replacement);
Expand Down
43 changes: 22 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
"rexreplace_ES6": "bin/ES6/cli.js"
},
"scripts": {
"test-minify": "npm run build-minify && npm run test-cli && npm run test-js",
"test": "npm run build && npm run test-cli && npm run test-js",
"test-minify": "yarn build-minify && yarn test-cli && yarn test-js",
"test": "yarn build && yarn test-cli && yarn test-js",
"postbuild": "cp bin/rexreplace.cli.js bin/rexreplace.cli.min.js",
"build": "npm run build-only",
"build": "yarn build-only",
"build-only": "tsc src/cli --outDir bin/ES6 -t ES6 && rollup -c",
"build-minify": "npm run build && npm run minify",
"build-minify": "yarn build && yarn minify",
"minify": "echo '#!/usr/bin/env node' > bin/rexreplace.cli.min.js && google-closure-compiler-js bin/rexreplace.cli.js >> bin/rexreplace.cli.min.js",
"prebuild": "rm -fr bin && npm run format",
"prebuild": "rm -fr bin && yarn format",
"test-js": "echo todo: async mocha",
"test-cli": "npm uninstall -g rexreplace && npm -g install ./ && npm run test-cli-only",
"test-cli": "npm uninstall -g rexreplace && npm -g install ./ && yarn test-cli-only",
"test-cli-only": "bash test/cli/run.sh",
"test-speed": "bash test/speed/run.sh",
"prepublishOnly": "git pull && npm run test-minify && npm run load-options",
"prepublishOnly": "git pull && yarn test-minify && yarn load-options",
"postpublish": "git add --all && git commit -m v$(node -e 'console.log(require(`./package.json`).version)') && git tag v$(node -e 'console.log(require(`./package.json`).version)') && git push && git push --tag && (open https://github.com/mathiasrw/rexreplace/releases || 1)",
"load-options": "rr -h | rr 'Options:([\\s\\S]+)Examples:' _ -m | rr '\n {26,}' ' ' | rr \"'\" '`' | rr '^ (-.+?), (--[^ ]+) *' '`€1` | **`€2`** ' | rr '(^---- . ----\n)[\\s\\S]*?(\n## Good to know)' '€1 + _pipe + €2' readme.md -jT",
"test-format": "yarn prettier --list-different || (echo 'Please correct file formatting using `npm run format` and try again.' && exit 1)",
"test-format": "yarn prettier --list-different || (echo 'Please correct file formatting using `yarn format` and try again.' && exit 1)",
"format": "yarn prettier --write",
"prettier": "prettier '{src,test}/**/*.{scss,css,js,ts}'"
},
Expand All @@ -45,26 +45,27 @@
"sed"
],
"devDependencies": {
"@types/node": "^13.1.2",
"assert": "^2.0.0",
"google-closure-compiler-js": "^20190909.0.0",
"mocha": "^6.0.0",
"prettier": "^1.12.1",
"re2": "^1.10.3",
"rollup": "^1.23.0",
"rollup-plugin-buble": "^0.19.2",
"mocha": "6.2.2",
"prettier": "1.19.1",
"re2": "1.10.5",
"rollup": "1.27.14",
"rollup-plugin-buble": "0.19.8",
"rollup-plugin-closure-compiler-js": "^1.0.6",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-filesize": "^6.0.0",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-filesize": "6.2.1",
"rollup-plugin-hashbang": "^1.0.1",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-preserve-shebang": "^0.1.6",
"rollup-plugin-progress": "^1.0.0",
"rollup-plugin-progress": "1.1.1",
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-typescript3": "^1.1.2",
"rollup-plugin-uglify": "^6.0.0",
"typescript": "^3.0.3",
"yarn": "^1.9.4"
"rollup-plugin-uglify": "6.0.4",
"typescript": "3.7.4",
"yarn": "1.21.1"
},
"directories": {
"test": "test"
Expand Down
9 changes: 7 additions & 2 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,10 @@ export function engine(config: any = {engine: 'V8'}) {
if (config.outputMatch) {
step('Output match');

if ('6' > process.versions.node) {
if (parseInt(process.versions.node) < 6) {
return die('outputMatch is only supported in node 6+');
}

return function() {
step(arguments);

Expand All @@ -228,7 +229,11 @@ export function engine(config: any = {engine: 'V8'}) {

// If captured groups then run dynamicly
//console.log(process);
if (config.replacementJs && /\$\d/.test(config.replacement) && process.versions.node < '6') {
if (
config.replacementJs &&
/\$\d/.test(config.replacement) &&
parseInt(process.versions.node) < 6
) {
return die('Captured groups for javascript replacement is only supported in node 6+');
}

Expand Down
Loading

0 comments on commit e64f8dd

Please sign in to comment.