From d0883134e892038fba36dff2bcd34da6912048b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20M=C3=A9ndez?= Date: Tue, 28 Apr 2020 12:09:29 +0200 Subject: [PATCH] chore: add comments on installTemplate method (#312) * chore: add comments on installTemplate method * improve explanation --- lib/generator.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/generator.js b/lib/generator.js index 8e17155ba..096ff15a6 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -286,13 +286,19 @@ class Generator { } else { // Template is not a filesystem path... const templatePath = path.resolve(DEFAULT_TEMPLATES_DIR, this.templateName); if (await isLocalTemplate(templatePath)) { + // This "if" is covering the following workflow: + // ag asyncapi.yaml ../html-template + // The previous command installs a template called @asyncapi/html-template + // And now we run the command again but with the resolved name: + // ag asyncapi.yaml @asyncapi/html-template + // The template name doesn't look like a file system path but we find + // that the package is already installed and it's a symbolic link. const { resolvedLink } = await getLocalTemplateDetails(templatePath); console.info(`This template has already been installed and it's pointing to your filesystem at ${resolvedLink}.`); } installedPkg = require(path.resolve(templatePath, PACKAGE_JSON_FILENAME)); } - return resolve({ name: installedPkg.name, version: installedPkg.version, @@ -303,6 +309,8 @@ class Generator { } } + // NOTE: npmi creates symbolic links inside DEFAULT_TEMPLATES_DIR + // (node_modules) for local packages, i.e., those located in the file system. npmi({ name: this.templateName, install: force,