-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from trentmwillis/inserter-refactor
Refactor meta replacement to allow for customizability
- Loading branch information
Showing
5 changed files
with
41 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
/** | ||
* Replace the manifest meta tag with an updated version of the manifest. | ||
* We do this in both the app's and test's index.html file. | ||
* | ||
* @private | ||
*/ | ||
var regex = /<meta name="([^"]*\/config\/asset-manifest)" content=[^>]*>/; | ||
|
||
function escaper(sourceJSON) { | ||
function transformer(sourceJSON) { | ||
return escape(JSON.stringify(sourceJSON)); | ||
} | ||
|
||
function replacer(fileContents, manifest) { | ||
function replacer(fileContents, metaContents) { | ||
if (!regex.test(fileContents)) { | ||
return fileContents; | ||
} | ||
|
||
var metaName = regex.exec(fileContents)[1]; | ||
var metaString = '<meta name="' + metaName + '" content="' + escaper(manifest) + '" />'; | ||
var metaString = '<meta name="' + metaName + '" content="' + metaContents + '" />'; | ||
|
||
return fileContents.replace(regex, metaString); | ||
} | ||
|
||
module.exports = { escaper, replacer }; | ||
module.exports = { transformer, replacer }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters