diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index d603903bb27f45485e1aa2f5a1064ab5b6bbecc3..bf2e1046d05f6b74679a2027b3b3a61364567be4 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -5,6 +5,12 @@ For a detailed view of what's changed, refer to the repository https://gitlab.co This project utilizes semantic versioning. +== Unreleased + +=== Changed + +* Look for npm in libexec/lib/node_modules when verifying the system Node.js installation (#46) (*@KalCramer*) + == 1.0.0-alpha.4 (2024-04-30) === Added diff --git a/docs/modules/ROOT/pages/antora-goal.adoc b/docs/modules/ROOT/pages/antora-goal.adoc index 8865a559d788e0cb7b2675a350a8aa6f8ca702d2..92fd2f3e610c06f55c0c47cae37851b339a662f2 100644 --- a/docs/modules/ROOT/pages/antora-goal.adoc +++ b/docs/modules/ROOT/pages/antora-goal.adoc @@ -127,6 +127,7 @@ The name or path of the Node.js executable to use. When this parameter is specified, a Node.js installation structure will be created under the location specified by the <> parameter that links (using symlinks) to the Node.js installation for the specified executable. In this scenario, Node.js will not be downloaded and installed locally and the <> parameter will be ignored. The location of the Node.js installation is determined by passing a script to the specified executable that reports the location where Node.js is installed. +The plugin validates the Node.js installation by looking for the npm binscript under [.path]_lib/node_modules_, [.path]_node_modules_, or [.path]_libexec/lib/node_modules_ relative to the node executable (aka binary). In order for the plugin to set up this link on Windows, developer mode must be enabled (so `mklink` can be used). If it isn't, the plugin will copy the Node.js installation instead of creating symlinks to it. diff --git a/src/main/java/org/antora/maven/SystemNodeLinker.java b/src/main/java/org/antora/maven/SystemNodeLinker.java index 3507b417ccf65df18c19e0fa7d79d7824174d2da..10078ee474916fa1ce76bc44462568ee4ac746a1 100644 --- a/src/main/java/org/antora/maven/SystemNodeLinker.java +++ b/src/main/java/org/antora/maven/SystemNodeLinker.java @@ -20,9 +20,9 @@ import static java.nio.file.Files.readSymbolicLink; public class SystemNodeLinker { private static final String RESOLVE_NODE_HOME_SCRIPT = "const p=require('path');" + - "function hasNpm(dir){try{require.resolve(p.join(dir,'npm/bin/npm-cli.js'));return dir}catch{}};" + "const exe=process.execPath,root=p.join(exe,p.basename(p.dirname(exe))==='bin'?'../..':'..');" + - "const pkgs=hasNpm(p.join(root,'lib/node_modules'))||hasNpm(p.join(root,'node_modules'))||'';" + + "function hasNpm(v){try{require.resolve(p.join((v=p.join(root,v)),'npm/bin/npm-cli.js'));return v}catch{}};" + + "const pkgs=hasNpm('lib/node_modules')||hasNpm('node_modules')||hasNpm('libexec/lib/node_modules')||'';" + "pkgs&&exe+'\\n'+pkgs+'\\n'+process.version"; private final Log log;