From f2e4b0172103525363bb87b6716f95dc5e83ea76 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 26 Feb 2016 12:50:28 -0800 Subject: [PATCH] [Templates] Add template paths ...with text! prefix --- scripts/migrate-templates.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/migrate-templates.js b/scripts/migrate-templates.js index 4e43e39a48..f9c1f3bcd8 100644 --- a/scripts/migrate-templates.js +++ b/scripts/migrate-templates.js @@ -46,12 +46,25 @@ function findTemplateURLs(sourceCode) { }); } +function injectRequireArgument(sourceCode, templateUrls) { + var lines = sourceCode.split('\n'), + index; + + templateUrls = _.uniq(templateUrls); + + index = lines.map(_.trim).indexOf("'legacyRegistry'"); + + lines = lines.slice(0, index).concat(templateUrls.map(function (url) { + return " \"text!./res/" + url + "\","; + }).concat(lines.slice(index))); + + return lines.join('\n'); +} + function migrate(file) { var sourceCode = fs.readFileSync(file, 'utf8'), templateUrls = findTemplateURLs(sourceCode); - templateUrls.forEach(function (templateUrl) { - console.log(templateUrl, toTemplateName(templateUrl)); - }); + console.log(injectRequireArgument(sourceCode, templateUrls)); } glob('platform/**/bundle.js', {}, function (err, files) {