Skip to content

Commit

Permalink
chore: add comments on installTemplate method (#312)
Browse files Browse the repository at this point in the history
* chore: add comments on installTemplate method

* improve explanation
  • Loading branch information
fmvilas authored Apr 28, 2020
1 parent 3e0c57b commit d088313
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit d088313

Please sign in to comment.