Fix template name extraction. Add keyword addition

This commit is contained in:
Erjan Gavalji
2015-04-02 11:51:15 +03:00
parent 556cf43fd4
commit 3cd333e2ed

View File

@@ -34,13 +34,15 @@ module.exports = function(grunt) {
return updatePackageDef(content, function(contentAsObject) {
contentAsObject.version = localCfg.packageVersion;
if (currentAppName.indexOf("template-") == 0) {
var templateName = currentAppName.substring(0, "template-".length);
var templateName = currentAppName.substring("template-".length);
contentAsObject.name = "tns-" + currentAppName;
contentAsObject.description = "Nativescript " + templateName + " template";
contentAsObject.keywords = addKeywords(contentAsObject.keywords, "template");
}
else {
contentAsObject.name = "tns-samples-" + currentAppName;
contentAsObject.description = "Nativescript " + currentAppName + " sample application";
contentAsObject.keywords = addKeywords(contentAsObject.keywords, "sample");
}
contentAsObject.license = "BSD";
if (!contentAsObject.repository) {
@@ -55,6 +57,16 @@ module.exports = function(grunt) {
});
};
var addKeywords = function(originalKeywords, newKeywords) {
var originalKeywordsArr = [];
if (typeof(originalKeywords) == "string") {
originalKeywordsArr = originalKeywords.split(" ");
}
var newKeywordsArr = newKeywords.split(" ");
var combinedKeywordsArr = originalKeywordsArr.concat(newKeywordsArr);
return combinedKeywordsArr.join(" ");
};
var updateDefinitionsPackageDef = function(content, srcPath) {
return updatePackageDef(content, function(contentAsObject) {
contentAsObject.version = localCfg.packageVersion;