Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ensure non-word char before and ( after. Support space around dot. #26

Merged
merged 2 commits into from

2 participants

@Qard

Fix for #25.

Ensure non-word character before and parenthesis after replacement. Also, support spaces/tabs/linebreaks around dot separator.

@Qard Qard Ensure non-word character before and parenthesis after replacement. A…
…lso, support spaces/tabs/linebreaks around dot separator.
a9ed9db
@blakmatrix
Owner

this unfortunately grabs too much and to little, , it'll grab non word characters like _- and even newlines, also by require the left parentheses this would fail on parts where the code is seperated out from the function call ie ( path.exists | foo )()

@Qard

That better?

@blakmatrix blakmatrix merged commit d1e82c6 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 7, 2012
  1. @Qard

    Ensure non-word character before and parenthesis after replacement. A…

    Qard authored
    …lso, support spaces/tabs/linebreaks around dot separator.
  2. @Qard

    Don't match _ or - and be more flexible about end character--just ens…

    Qard authored
    …ure it's not a word-character, like the start
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 8 deletions.
  1. +8 −8 app.js
View
16 app.js
@@ -66,8 +66,8 @@ botOptions.changesList = [
message: '[fix] path.exists was moved to fs.exists',
func: function (fileList, settings, cb) {
async.map(fileList, function (file, callback) {
- var re = /path\.\bexists\b/g;
- fileReplace(file, re, "fs.exists", callback);
+ var re = /([^[0-9a-zA-Z_-]])path(\s*.\s*exists\s*[^[0-9a-zA-Z_-]])/g;
+ fileReplace(file, re, "$1fs$2", callback);
}, function (err, results) {
// results is now an array of stats for each file
if (err) {
@@ -85,8 +85,8 @@ botOptions.changesList = [
message: '[fix] path.existsSync was moved to fs.existsSync',
func: function (fileList, settings, cb) {
async.map(fileList, function (file, callback) {
- var re = /path\.\bexistsSync\b/g;
- fileReplace(file, re, "fs.existsSync", callback);
+ var re = /([^[0-9a-zA-Z_-]])path(\s*.\s*existsSync\s*[^[0-9a-zA-Z_-]])/g;
+ fileReplace(file, re, "$1fs$2", callback);
}, function (err, results) {
// results is now an array of stats for each file
if (err) {
@@ -104,8 +104,8 @@ botOptions.changesList = [
message: '[fix] tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())',
func: function (fileList, settings, cb) {
async.map(fileList, function (file, callback) {
- var re = /tty\.\bsetRawMode\b/g;
- fileReplace(file, re, "process.stdin.setRawMode", callback);
+ var re = /([^[0-9a-zA-Z_-]])tty(\s*.\s*setRawMode\s*[^[0-9a-zA-Z_-]])/g;
+ fileReplace(file, re, "$1process.stdin$2", callback);
}, function (err, results) {
// results is now an array of stats for each file
if (err) {
@@ -236,9 +236,9 @@ function fileReplace(filename, re, replacement, cb) {
var dataStr = data.toString(),
fixedDoc = '';
- if (XRegExp.test(dataStr, re)) {
+ if (re.test(dataStr)) {
- fixedDoc = XRegExp.replace(dataStr, re, replacement, 'all');
+ fixedDoc = dataStr.replace(re, replacement);
// write changes out to file
fs.writeFile(filename, fixedDoc, function (err) {
Something went wrong with that request. Please try again.