Improve keywords

This commit is contained in:
Erjan Gavalji
2015-04-02 14:05:55 +03:00
parent 3cd333e2ed
commit 91c1d5e3ad

View File

@@ -33,18 +33,22 @@ module.exports = function(grunt) {
var currentAppName = grunt.task.current.data.appName; var currentAppName = grunt.task.current.data.appName;
return updatePackageDef(content, function(contentAsObject) { return updatePackageDef(content, function(contentAsObject) {
contentAsObject.version = localCfg.packageVersion; contentAsObject.version = localCfg.packageVersion;
contentAsObject.author = "Telerik <support@telerik.com>";
var specificKeywords = ["telerik", "mobile"];
if (currentAppName.indexOf("template-") == 0) { if (currentAppName.indexOf("template-") == 0) {
var templateName = currentAppName.substring("template-".length); var templateName = currentAppName.substring("template-".length);
contentAsObject.name = "tns-" + currentAppName; contentAsObject.name = "tns-" + currentAppName;
contentAsObject.description = "Nativescript " + templateName + " template"; contentAsObject.description = "Nativescript " + templateName + " template";
contentAsObject.keywords = addKeywords(contentAsObject.keywords, "template"); specificKeywords.push("template");
} }
else { else {
contentAsObject.name = "tns-samples-" + currentAppName; contentAsObject.name = "tns-samples-" + currentAppName;
contentAsObject.description = "Nativescript " + currentAppName + " sample application"; contentAsObject.description = "Nativescript " + currentAppName + " sample application";
contentAsObject.keywords = addKeywords(contentAsObject.keywords, "sample"); specificKeywords.push("sample");
} }
contentAsObject.license = "BSD"; contentAsObject.license = "BSD";
addKeywords(contentAsObject, specificKeywords);
if (!contentAsObject.repository) { if (!contentAsObject.repository) {
contentAsObject.repository = {}; contentAsObject.repository = {};
} }
@@ -57,14 +61,16 @@ module.exports = function(grunt) {
}); });
}; };
var addKeywords = function(originalKeywords, newKeywords) { var addKeywords = function(packageObject, newKeywords) {
var originalKeywordsArr = []; if (!packageObject.keywords) {
if (typeof(originalKeywords) == "string") { packageObject.keywords = newKeywords;
originalKeywordsArr = originalKeywords.split(" "); return;
} }
var newKeywordsArr = newKeywords.split(" ");
var combinedKeywordsArr = originalKeywordsArr.concat(newKeywordsArr); if (typeof(packageObject.keywords) == "string") {
return combinedKeywordsArr.join(" "); packageObject.keywords = packageObject.keywords.split(" ");
}
packageObject.keywords = packageObject.keywords.concat(newKeywords);
}; };
var updateDefinitionsPackageDef = function(content, srcPath) { var updateDefinitionsPackageDef = function(content, srcPath) {