Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refine require.js regex

  • Loading branch information...
commit 0a6dbdc892d595e64773faf6e9140c5eb0c633bb 1 parent bf442c9
@techjacker authored
Showing with 9 additions and 3 deletions.
  1. +8 −2 lib/replace-text.js
  2. +1 −1  package.json
View
10 lib/replace-text.js
@@ -55,7 +55,8 @@ var ReplaceText = function (opts) {
// regexes
this.oldVersionFileNameRegex = new RegExp(this.regedFileNameBeg + '\\.[a-z0-9]+' + this.regedFileNameSuffix + '$', "ig");
this.fileNameRegex = new RegExp(this.regedFileNameBeg + '(\\.[a-z0-9]+' + this.regedFileNameSuffix + ')|' + this.regedFileNameBeg + '(' + this.regedFileNameSuffix + ')', "ig");
- this.fileNameRegexRequireJs = new RegExp(this.regedFileNameBeg + '\\.[a-z0-9]+(?!' + this.regedFileNameSuffix + ')(?!=)|' + this.regedFileNameBeg + '(?!' + this.regedFileNameSuffix + ')(?!=)', "ig");
+ // this.fileNameRegexRequireJs = new RegExp(this.regedFileNameBeg + '\\.[a-z0-9]+(?!' + this.regedFileNameSuffix + ')(?!=)|' + this.regedFileNameBeg + '(?!' + this.regedFileNameSuffix + ')(?!=)', "ig");
+ this.fileNameRegexRequireJs = new RegExp(this.regedFileNameBeg + '\\.[a-z0-9]+(?!' + this.regedFileNameSuffix + ')(?!=)("|\')|' + this.regedFileNameBeg + '(?!' + this.regedFileNameSuffix + ')(?!=)("|\')', "ig");
return _(this).bindAll('assignNewVersion', 'addOutputFileAttrs', 'run');
};
@@ -98,7 +99,12 @@ ReplaceText.prototype.run = function (haystack, overrideRequireJs) {
haystack = haystack.replace(this.fileNameRegex, newfileNameStem + this.fileNameSuffix);
if (this.requireJs && overrideRequireJs !== true) {
- haystack = haystack.replace(this.fileNameRegexRequireJs, newfileNameStem);
+
+ haystack = haystack.replace(this.fileNameRegexRequireJs, function (str, p1, p2, s) {
+ var closingQuote = p1 || p2 || '';
+ return newfileNameStem + closingQuote;
+ });
+
haystack = haystack.replace(this.fileNameRegex, newfileNameStem + this.fileNameSuffix);
}
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "node-version-assets",
- "version": "0.0.8",
+ "version": "0.0.9",
"description": "version your static assets",
"main": "index.js",
"scripts": {
Please sign in to comment.
Something went wrong with that request. Please try again.