Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails on certain regex string. #99

Closed
rhys-vdw opened this issue Jun 30, 2014 · 7 comments
Closed

Fails on certain regex string. #99

rhys-vdw opened this issue Jun 30, 2014 · 7 comments

Comments

@rhys-vdw
Copy link

The following code:

  }).filter('formatPhoneNumber', function() {
    return function(phoneNumber) {
      return phoneNumber.replace(/[()- ]/gi, '');
    };

Causes ng-min to shit itself with the following stacktrace.

sprima.js:3062:20)
  at parseSourceElements (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/ngmin/node_modules/esprima/esprima.js:3095:29)
  at parseProgram (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/ngmin/node_modules/esprima/esprima.js:3109:19)
  at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/ngmin/node_modules/esprima/esprima.js:3609:38
  at Object.parse (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/ngmin/node_modules/esprima/esprima.js:3856:23)
  at Object.exports.annotate (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/ngmin/main.js:16:21)
  at Transform._transform (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/index.js:19:37)
  at Transform._read (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
  at Transform._write (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
  at doWrite (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:238:10)
  at writeOrBuffer (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:228:5)
  at Transform.Writable.write (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ngmin/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:195:11)
  at Stream.ondata (stream.js:51:26)
  at Stream.EventEmitter.emit (events.js:95:17)
  at Stream.modifyFile (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-coffee/index.js:52:10)
  at Stream.stream.write (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-coffee/node_modules/event-stream/node_modules/through/index.js:26:11)
  at Stream.ondata (stream.js:51:26)
  at Stream.EventEmitter.emit (events.js:95:17)
  at queueData (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp/node_modules/vinyl-fs/node_modules/map-stream/index.js:43:21)
  at next (/Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp/node_modules/vinyl-fs/node_modules/map-stream/index.js:71:7)
  at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp/node_modules/vinyl-fs/node_modules/map-stream/index.js:85:7
  at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp/node_modules/vinyl-fs/lib/src/bufferFile.js:8:5
  at fs.js:266:14
  at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp-ruby-sass/node_modules/temp-write/node_modules/graceful-fs/graceful-fs.js:104:5
  at /Users/rhysvanderwaerden/Projects/hummingbird/hummingbird-frontend/node_modules/gulp/node_modules/vinyl-fs/node_modules/graceful-fs/graceful-fs.js:104:5
  at Object.oncomplete (fs.js:107:15)

Removing the space in the regex string fixes the problem.

I'm using gulp-ngmin 0.3.0, and ng-min 0.5.0.

@eddiemonge
Copy link
Collaborator

Try using ng-annotate and if that doesn't work then file an issue there

@rhys-vdw
Copy link
Author

rhys-vdw commented Jul 2, 2014

Is ng-min deprecated now?

@olov
Copy link

olov commented Jul 2, 2014

~/projects/ng-annotate % ng-annotate -a issue99.js
error: couldn't process source due to parse error
Line 1: Invalid regular expression

Change your regexp to [()\- ]/gi and it works fine.

@rhys-vdw
Copy link
Author

rhys-vdw commented Jul 2, 2014

Ah yeah, cheers, but fixing it is not a problem. It's more problematic that
it crashes ng-min. If I had made more than one change before saving I would
have been mighty confused!

On 2 July 2014 17:59, Olov Lassus notifications@github.com wrote:

~/projects/ng-annotate % ng-annotate -a issue99.js
error: couldn't process source due to parse error
Line 1: Invalid regular expression

Change your regexp to [()- ]/gi and it works fine.


Reply to this email directly or view it on GitHub
#99 (comment).

@olov
Copy link

olov commented Jul 2, 2014

Sure. Feel free to try out ng-annotate. As you can see in my previous comment it gives you a friendly error message on your broken regexp. (To be fair, Esprima does). If it gives you any problem then file an issue and we'll fix it.

For more info on ng-annotate and ngmin, see The future of ngmin and ng-annotate.

@eddiemonge
Copy link
Collaborator

@rhys-vdw You can consider ng-min deprecated. As soon as I get time I am going to implement the changes in that issue @olov linked you to

@rhys-vdw
Copy link
Author

rhys-vdw commented Jul 3, 2014

Thanks guys. I'll switch over to ng-annotate before I go live and raise any
relevant issues there.

On 3 July 2014 03:30, Eddie Monge notifications@github.com wrote:

Closed #99 #99.


Reply to this email directly or view it on GitHub
#99 (comment).

olov added a commit to olov/ng-annotate that referenced this issue Jul 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants