From 4a258a242723dd23ceb080f2a70323136c72bdab Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 4 Jan 2021 19:32:30 +0000 Subject: [PATCH] Generator: Better handling of package.json keywords --- packages/generator-joplin/generators/app/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/generator-joplin/generators/app/index.js b/packages/generator-joplin/generators/app/index.js index 9083aeafef..345d6efa31 100644 --- a/packages/generator-joplin/generators/app/index.js +++ b/packages/generator-joplin/generators/app/index.js @@ -9,7 +9,14 @@ function mergePackageKey(parentKey, source, dest) { const output = Object.assign({}, dest); for (const k in source) { - if (!(k in output)) { + if (k === 'keywords' && !Array.isArray(output[k])) { + // Fix an earlier bugs where keywords were set to an empty object + output[k] = source[k]; + } else if (k === 'keywords') { + // For keywords, make sure to add the "joplin-plugin" one + if (!output['keywords']) output['keywords'] = []; + if (output['keywords'].indexOf('joplin-plugin') < 0) output['keywords'].push('joplin-plugin'); + } else if (!(k in output)) { // If the key doesn't exist in the destination, add it output[k] = source[k]; } else if (parentKey === 'devDependencies') {