mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix template name extraction. Add keyword addition
This commit is contained in:
14
gruntfile.js
14
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;
|
||||
|
||||
Reference in New Issue
Block a user