Odd JavaScript issue

Update Fixed! With this tweet Jim Lind has saved my day.

So, I’m working on issue #52 for Unmark and I’m having what is quickly becoming the oddest issue I’ve ever had in my professional career.

As with most programming oddities, I’m willing to bet that when the issue is found it will be something completely obvious and stupid on my part. But, on the chance that someone out there can help me here is what is going on.

Every time I edit and then compile Unmark’s JavaScript using Grunt I end up with “illegal” characters at the end of the one of the files. It is only if I edit the files that I end up with “illegal” characters. If I put the file back to its original state – even manually using my text editor – and run Grunt again all is well. I’ve never had this issue with any other file or project until yesterday with this one.

I’m using Sublime Text Build 3065, running Vagrant to run a Virtual Box for my Unmark development environment, and that box is a typical LAMP set up. If you need any of these specific details – or you think they’d be appropriate to include in this post – hit me up on the tweet box and I’ll add them.

Here is how you reproduce the problem (assuming it isn’t something specific on my computer).

  1. Clone the Unmark repo and follow the set up instructions found on GitHub.
  2. Verify that Unmark runs properly.
  3. Open /assets/js/unmark.marks.js in your text editor
  4. Edit any line or add a random console.log(’hi’); somewhere in the file.
  5. Save it, run “grunt” again

You shouldn’t get any errors or warnings from Grunt. If you do, you may have a Gruntfile that says ‘uglify:custom’ or ‘concat:custom’ — which is looking for a custom folder in the Unmark directory. It is our way of allowing anyone that wants to build on top of Unmark to do so non-destructively. Anyway… you can get rid of those in the Gruntfile if it gives you issues.

Now, load Unmark. It will likely error and give you something that looks like this. And the JavaScript file (now found at /assets/js/production/unmark.loggedin.js) will have some odd characters at the end and look like this.

I do not know why. I’ve been scratching at this for several hours and I have yet to figure it out.