mirror of
https://github.com/nasa/openmct.git
synced 2024-12-22 06:27:48 +00:00
[Templates] Create variable names by template URL
This commit is contained in:
parent
4666292907
commit
930fed83e8
@ -29,18 +29,29 @@ var glob = require('glob'),
|
|||||||
path = require('path'),
|
path = require('path'),
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
|
|
||||||
|
function toTemplateName(templateUrl) {
|
||||||
|
var parts = templateUrl.split('/');
|
||||||
|
return _.camelCase(parts[parts.length - 1].replace(".html", "")) +
|
||||||
|
"Template";
|
||||||
|
}
|
||||||
|
|
||||||
function findTemplateURLs(sourceCode) {
|
function findTemplateURLs(sourceCode) {
|
||||||
return sourceCode.split('\n')
|
return sourceCode.split('\n')
|
||||||
.map(_.trim)
|
.map(_.trim)
|
||||||
.filter(function (line) {
|
.filter(function (line) {
|
||||||
return line.indexOf("templateUrl") !== -1;
|
return line.indexOf("templateUrl") !== -1;
|
||||||
|
})
|
||||||
|
.map(function (line) {
|
||||||
|
return _.trim(line.split(":")[1], "\", ");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrate(file) {
|
function migrate(file) {
|
||||||
var sourceCode = fs.readFileSync(file, 'utf8'),
|
var sourceCode = fs.readFileSync(file, 'utf8'),
|
||||||
templateUrls = findTemplateURLs(sourceCode);
|
templateUrls = findTemplateURLs(sourceCode);
|
||||||
console.log(templateUrls);
|
templateUrls.forEach(function (templateUrl) {
|
||||||
|
console.log(templateUrl, toTemplateName(templateUrl));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
glob('platform/**/bundle.js', {}, function (err, files) {
|
glob('platform/**/bundle.js', {}, function (err, files) {
|
||||||
|
Loading…
Reference in New Issue
Block a user