$ show asdf-vm/asdf-nodejs
This is an asdf plugin for managing Node.js versions. It provides commands to install, list, and resolve Node.js versions using node-build under the hood. The plugin supports legacy version files (.nvmrc, .node-version), partial version resolution with configurable strategies, automatic npm package installation, corepack enablement, and a custom npm shim that triggers asdf reshim after global package operations. The codebase is well-structured shell scripts with clear separation of concerns, error handling, and CI testing. It is actively maintained and follows asdf plugin conventions.
The LLM identified 2 files worth highlighting for reuse:
A shim that wraps the npm binary to detect global install/uninstall commands and automatically run `asdf reshim` after them. It demonstrates a clean pattern for intercepting CLI commands, parsing arguments, and conditionally executing side effects while preserving the original command's behavior. The logic for detecting global operations and the fallback search for the canonical npm binary are well-implemented and reusable for similar wrapper scenarios.
Contains the core version resolution logic including mapping Node.js codenames (e.g., lts/hydrogen) to major versions, resolving partial versions using configurable strategies (latest_installed or latest_available), and sorting version strings. The `resolve_version` function is a self-contained, parameterized utility that could be extracted for use in other version management tools. It handles edge cases like legacy file dynamic strategies and fallback behavior.