From 3cd333e2edfb988d81f8b0e0c2dfb0c16dc654b4 Mon Sep 17 00:00:00 2001 From: Erjan Gavalji Date: Thu, 2 Apr 2015 11:51:15 +0300 Subject: [PATCH] Fix template name extraction. Add keyword addition --- gruntfile.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gruntfile.js b/gruntfile.js index c19f45151..a8ae3a331 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -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;