mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-12 17:49:08 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
00f3ba0831 | ||
![]() |
0f1efc825e |
@@ -1,17 +0,0 @@
|
||||
HEAD
|
||||
.cache
|
||||
v*
|
||||
alias
|
||||
|
||||
# For testing
|
||||
test/bak
|
||||
.urchin.log
|
||||
.urchin_stdout
|
||||
test/**/test_output
|
||||
test/**/.nvmrc
|
||||
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
.DS_Store
|
||||
current
|
@@ -1,35 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
tab_width = 2
|
||||
indent_size = 2
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.txt]
|
||||
indent_size = false
|
||||
|
||||
[test/fast/Listing versions/Running 'nvm ls' calls into nvm_alias]
|
||||
indent_size = false
|
||||
|
||||
[test/fast/Listing versions/Running 'nvm ls --no-alias' does not call into nvm_alias]
|
||||
indent_size = false
|
||||
|
||||
[test/fast/Unit tests/mocks/**]
|
||||
insert_final_newline = off
|
||||
|
||||
[test/**/.urchin*]
|
||||
insert_final_newline = off
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
[test/fixtures/nvmrc/**]
|
||||
indent_style = off
|
||||
insert_final_newline = off
|
||||
|
||||
[test/fixtures/actual/alias/empty]
|
||||
insert_final_newline = off
|
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1 +0,0 @@
|
||||
* text=auto eol=lf
|
12
.github/FUNDING.yml
vendored
12
.github/FUNDING.yml
vendored
@@ -1,12 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/nvm
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
117
.github/INCIDENT_RESPONSE_PLAN.md
vendored
117
.github/INCIDENT_RESPONSE_PLAN.md
vendored
@@ -1,117 +0,0 @@
|
||||
# Incident Response Process for **nvm**
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
We take the security of **nvm** very seriously. If you believe you’ve found a security vulnerability, please inform us responsibly through coordinated disclosure.
|
||||
|
||||
### How to Report
|
||||
|
||||
> **Do not** report security vulnerabilities through public GitHub issues, discussions, or social media.
|
||||
|
||||
Instead, please use one of these secure channels:
|
||||
|
||||
1. **GitHub Security Advisories**
|
||||
Use the **Report a vulnerability** button in the Security tab of the [nvm-sh/nvm repository](https://github.com/nvm-sh/nvm).
|
||||
|
||||
2. **Email**
|
||||
Follow the posted [Security Policy](https://github.com/nvm-sh/nvm/security/policy).
|
||||
|
||||
### What to Include
|
||||
|
||||
**Required Information:**
|
||||
- Brief description of the vulnerability type
|
||||
- Affected version(s) and components
|
||||
- Steps to reproduce the issue
|
||||
- Impact assessment (what an attacker could achieve)
|
||||
|
||||
**Helpful Additional Details:**
|
||||
- Full paths of affected scripts or files
|
||||
- Specific commit or branch where the issue exists
|
||||
- Required configuration to reproduce
|
||||
- Proof-of-concept code (if available)
|
||||
- Suggested mitigation or fix
|
||||
|
||||
## Our Response Process
|
||||
|
||||
**Timeline Commitments:**
|
||||
- **Initial acknowledgment**: Within 24 hours
|
||||
- **Detailed response**: Within 3 business days
|
||||
- **Status updates**: Every 7 days until resolved
|
||||
- **Resolution target**: 90 days for most issues
|
||||
|
||||
**What We’ll Do:**
|
||||
1. Acknowledge your report and assign a tracking ID
|
||||
2. Assess the vulnerability and determine severity
|
||||
3. Develop and test a fix
|
||||
4. Coordinate disclosure timeline with you
|
||||
5. Release a security update and publish an advisory and CVE
|
||||
6. Credit you in our security advisory (if desired)
|
||||
|
||||
## Disclosure Policy
|
||||
|
||||
- **Coordinated disclosure**: We’ll work with you on timing
|
||||
- **Typical timeline**: 90 days from report to public disclosure
|
||||
- **Early disclosure**: If actively exploited
|
||||
- **Delayed disclosure**: For complex issues
|
||||
|
||||
## Scope
|
||||
|
||||
**In Scope:**
|
||||
- **nvm** project (all supported versions)
|
||||
- Installation and update scripts (`install.sh`, `nvm.sh`)
|
||||
- Official documentation and CI/CD integrations
|
||||
- Dependencies with direct security implications
|
||||
|
||||
**Out of Scope:**
|
||||
- Third-party forks or mirrors
|
||||
- Platform-specific installs outside core scripts
|
||||
- Social engineering or physical attacks
|
||||
- Theoretical vulnerabilities without practical exploitation
|
||||
|
||||
## Security Measures
|
||||
|
||||
**Our Commitments:**
|
||||
- Regular vulnerability scanning via GitHub Actions
|
||||
- Automated security checks in CI/CD pipelines
|
||||
- Secure scripting practices and mandatory code review
|
||||
- Prompt patch releases for critical issues
|
||||
|
||||
**User Responsibilities:**
|
||||
- Keep **nvm** updated
|
||||
- Verify script downloads via PGP signatures
|
||||
- Follow secure configuration guidelines for shell environments
|
||||
|
||||
## Legal Safe Harbor
|
||||
|
||||
**We will NOT:**
|
||||
- Initiate legal action
|
||||
- Contact law enforcement
|
||||
- Suspend or terminate your access
|
||||
|
||||
**You must:**
|
||||
- Only test against your own installations
|
||||
- Not access, modify, or delete user data
|
||||
- Not degrade service availability
|
||||
- Not publicly disclose before coordinated disclosure
|
||||
- Act in good faith
|
||||
|
||||
## Recognition
|
||||
|
||||
- **Advisory Credits**: Credit in GitHub Security Advisories (unless anonymous)
|
||||
|
||||
## Security Updates
|
||||
|
||||
**Stay Informed:**
|
||||
- Subscribe to GitHub releases for **nvm**
|
||||
- Enable GitHub Security Advisory notifications
|
||||
|
||||
**Update Process:**
|
||||
- Patch releases (e.g., v0.40.3 → v0.40.4)
|
||||
- Out-of-band releases for critical issues
|
||||
- Advisories via GitHub Security Advisories
|
||||
|
||||
## Contact Information
|
||||
|
||||
- **Security reports**: Security tab of [nvm-sh/nvm](https://github.com/nvm-sh/nvm/security)
|
||||
- **General inquiries**: GitHub Discussions or Issues
|
||||
|
1
.github/ISSUE_TEMPLATE/config.yml
vendored
1
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +0,0 @@
|
||||
blank_issues_enabled: false
|
52
.github/ISSUE_TEMPLATE/issue_template.md
vendored
52
.github/ISSUE_TEMPLATE/issue_template.md
vendored
@@ -1,52 +0,0 @@
|
||||
---
|
||||
name: File an issue…
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Thank you for being interested in nvm! Please help us by filling out the following form if you‘re having trouble. If you have a feature request, or some other question, please feel free to clear out the form. Thanks! -->
|
||||
|
||||
#### Operating system and version:
|
||||
|
||||
#### `nvm debug` output:
|
||||
<details>
|
||||
<!-- do not delete the following blank line -->
|
||||
|
||||
```sh
|
||||
|
||||
```
|
||||
</details>
|
||||
|
||||
#### `nvm ls` output:
|
||||
<details>
|
||||
<!-- do not delete the following blank line -->
|
||||
|
||||
```sh
|
||||
|
||||
```
|
||||
</details>
|
||||
|
||||
#### How did you install `nvm`?
|
||||
<!-- (e.g. install script in readme, Homebrew) -->
|
||||
|
||||
#### What steps did you perform?
|
||||
|
||||
#### What happened?
|
||||
|
||||
#### What did you expect to happen?
|
||||
|
||||
#### Is there anything in any of your profile files that modifies the `PATH`?
|
||||
<!-- (e.g. `.bashrc`, `.bash_profile`, `.zshrc`, etc) -->
|
||||
|
||||
<!-- Please remove the following section if it does not apply to you -->
|
||||
#### If you are having installation issues, or getting "N/A", what does `curl -I --compressed -v https://nodejs.org/dist/` print out?
|
||||
<details>
|
||||
<!-- do not delete the following blank line -->
|
||||
|
||||
```sh
|
||||
|
||||
```
|
||||
</details>
|
28
.github/SECURITY.md
vendored
28
.github/SECURITY.md
vendored
@@ -1,28 +0,0 @@
|
||||
# Security
|
||||
|
||||
Please file a private vulnerability report via GitHub, email [@ljharb](https://github.com/ljharb), or see https://tidelift.com/security if you have a potential security vulnerability to report.
|
||||
|
||||
## OpenSSF CII Best Practices
|
||||
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||
|
||||
There are three “tiers”: passing, silver, and gold.
|
||||
|
||||
### Passing
|
||||
We meet 100% of the “passing” criteria.
|
||||
|
||||
### Silver
|
||||
We meet 100% of the “silver” criteria.
|
||||
|
||||
### Gold
|
||||
We meet 78% of the “gold” criteria. The gaps are as follows:
|
||||
- because we only have one maintainer, the project has no way to continue if that maintainer stops being active.
|
||||
- We do not include a copyright or license statement in each source file. Efforts are underway to change this archaic practice into a suggestion instead of a hard requirement.
|
||||
|
||||
## Threat Model
|
||||
|
||||
See [THREAT_MODEL.md](.github/THREAT_MODEL.md).
|
||||
|
||||
## Incident Response Plan
|
||||
|
||||
Please see our [Incident Response Plan](.github/INCIDENT_RESPONSE_PLAN.md).
|
109
.github/THREAT_MODEL.md
vendored
109
.github/THREAT_MODEL.md
vendored
@@ -1,109 +0,0 @@
|
||||
# `nvm` Threat Model
|
||||
|
||||
## Introduction
|
||||
|
||||
Threat model analysis assists organizations to proactively identify potential security threats and vulnerabilities, enabling them to develop effective strategies to mitigate these risks before they are exploited by attackers.
|
||||
Furthermore, this often helps to improve the overall security and resilience of a system or application.
|
||||
|
||||
The aim of this section is to facilitate the identification of potential security threats and vulnerabilities that may be exploited by adversaries, along with possible outcomes and appropriate mitigations.
|
||||
|
||||
## Relevant assets and threat actors
|
||||
|
||||
The following assets are considered important for the `nvm` project:
|
||||
- `nvm` source code and project documentation
|
||||
- Underlying `nvm` dependencies
|
||||
- `nvm` development infrastructure
|
||||
- `nvm` installed devices including servers
|
||||
|
||||
The following threat actors are considered relevant to the `nvm` application:
|
||||
- External malicious attackers
|
||||
- Internal malicious attackers
|
||||
- Services
|
||||
- Malicious insider actors
|
||||
- Third-party libraries
|
||||
|
||||
## Attack surface for external/internal attackers and services
|
||||
|
||||
In threat modeling, an attack surface refers to any possible point of entry that an attacker might use to exploit a system or application.
|
||||
This includes all the paths and interfaces that an attacker may use to access, manipulate or extract sensitive data from a system.
|
||||
By understanding the attack surface, organizations are typically able to identify potential attack vectors and implement appropriate countermeasures to mitigate risks.
|
||||
|
||||
In the following diagrams, _External Malicious Attacker_ applies to threat actors who do not yet have direct access to the `nvm` application and the underlying operating system, while the _Internal Malicious Attacker_ applies to an attacker with access to the device (computer, server), potentially after successfully exploiting a threat from the _External Malicious Attacker_ scenario.
|
||||
**Please note that some of the external threats may be also exploitable from internal threats and vice versa.**
|
||||
|
||||
<img src="./external-threat-actor.png" alt="Fig.: Possible attacks from internal and external threat actors and services" />
|
||||
Fig.: Possible attacks from internal and external threat actors and services
|
||||
|
||||
## Identified threats
|
||||
|
||||
The identified threats against the `nvm` application are as follows:
|
||||
|
||||
### Threat ID 1: `nvm` commands
|
||||
|
||||
Overview: The `nvm` commands and subcommands take user input for handling and executing appropriate functions from the project directory (or any parent directory).
|
||||
When user-controlled inputs are not adequately validated and later passed to the `nvm` functions as a part of a command, an attacker might be able to execute operating system commands triggered by any parsing functionality.
|
||||
|
||||
Possible Outcome: Attacks against `nvm` commands could lead to unauthorized access to user data or unauthorized access to the device (i.e. laptop or server, depending on where `nvm` is installed), resulting in loss of user private data stored on the device, among other possibilities.
|
||||
|
||||
Recommendation: Input validation should be implemented to prevent attackers from requesting operating system commands.
|
||||
Similarly, secure coding practices ought to be in place to minimize the risk of buffer overflow vulnerabilities.
|
||||
|
||||
### Threat ID 2: URI scheme
|
||||
|
||||
Overview: `nvm` commands heavily use the [Secure HyperText Transfer](https://datatracker.ietf.org/doc/html/rfc2660) protocol for `nvm` related actions.
|
||||
Missing [scheme](https://datatracker.ietf.org/doc/html/rfc3986#section-3.1) validation for any `nvm` command might result in file retrieval, enumeration, file overwrite, or [path traversal](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/05-Authorization_Testing/01-Testing_Directory_Traversal_File_Include) attacks.
|
||||
An example of this could be path validation for [`nvm_download`](https://github.com/nvm-sh/nvm/blob/ef7fc2f2c06ad75fe7fbabf28d427561ae7b007d/nvm.sh#L118), among many other possibilities.
|
||||
|
||||
Possible Outcome: Security misconfiguration flaws for URI scheme may lead to unauthorized access to user data, as well as data integrity compromises.
|
||||
|
||||
Recommendation: Adequate input validation should be implemented to prevent attackers from enumerating, retrieving and writing to application files and paths.
|
||||
|
||||
### Threat ID 3: Communication channel
|
||||
|
||||
Overview: The `nvm` commands and its subcommands use network protocol to communicate with external services.
|
||||
Insecure communication may allow malicious attackers to perform [_Man-in-the-Middle_](https://owasp.org/www-community/attacks/Manipulator-in-the-middle_attack) attacks in order to manipulate the data sent during the users’ active connection.
|
||||
|
||||
Possible Outcome: Usage of plaintext communication protocols, like HTTP could lead to data sniffing and modification through insecure communications channels.
|
||||
|
||||
Recommendation: Mitigation countermeasures such as data encryption should be in place to prevent data manipulation via insecure communication channels.
|
||||
|
||||
### Threat ID 4: Environment variables
|
||||
|
||||
Overview: Each `nvm` installation defines its environment variables, which should be secured from internal malicious attackers, preventing access control attack vectors.
|
||||
Missing stringent restrictions on setting variables, might allow attackers to prepare various targeted attacks against other local users, who use `nvm` in their user space.
|
||||
For example, [_Privilege Escalation_](https://owasp.org/Top10/A01_2021-Broken_Access_Control/), [_Command Injection_](https://cwe.mitre.org/data/definitions/77.html), as well as many other parser-related attacks.
|
||||
|
||||
Possible Outcome: Attacks against environment variables could lead to unauthorized access to the user space, resulting in the loss of user private data and disruptions in service availability.
|
||||
|
||||
Recommendation: Adequate hardening of configuration file permissions should be in place for all relevant configuration files, as this provides protection against attackers able to manipulate variables and inject malicious code.
|
||||
|
||||
## Attack surface for malicious insider actors and third-party libraries
|
||||
|
||||
The following diagram summarizes the main possible threats against the `nvm` project from malicious insider actors and third-party libraries:
|
||||
|
||||
<img src="./insider-threat-actor-and-libs.png" alt="Fig.: Possible attacks from insider threat actors and third-party libraries" />
|
||||
Fig.: Possible attacks from insider threat actors and third-party libraries
|
||||
|
||||
The identified threats against the `nvm` project are as follows:
|
||||
|
||||
### Threat ID 1: Insider threat actor
|
||||
|
||||
**Overview**: An insider threat actor, such as an `nvm` project contributor or employee with access to the code base, might abuse their role in the organization to modify the `nvm` application source code.
|
||||
For example, intentionally adding malicious code snippets, clearing logs after being written and/or modifying specific sections of the documentation.
|
||||
|
||||
**Possible Outcome**: Reputation damage, financial losses.
|
||||
|
||||
**Recommendation**: Secure coding practices, code reviews, automated code scanning and separation of duties (i.e. requiring at least two developers to approve any code change) are potentially useful security controls to identify and mitigate vulnerabilities that may be introduced by an insider threat actor.
|
||||
|
||||
### Threat ID 2: Third-party libraries
|
||||
|
||||
**Overview**: Please note that while `nvm` does not currently make use of any third-party libraries, this might become an attack vector if that changes in the future.
|
||||
Third-party libraries may introduce potential risks related to maintaining security requirements by third-party vendors.
|
||||
As a result, third-party libraries used by the `nvm` project, might contain vulnerabilities, such as [_Buffer Overflows_](https://owasp.org/www-community/vulnerabilities/Buffer_Overflow), [_Format String Vulnerabilities_](https://owasp.org/www-community/attacks/Format_string_attack), as well as many other types of weaknesses that, in a worst-case scenario may lead to _Remote Code Execution_ (_RCE_).
|
||||
Additionally, the maintainer of a third-party dependency might introduce a vulnerability on purpose, or be compromised by an attacker that subsequently introduces vulnerable code.
|
||||
|
||||
**Possible Outcome**: Code vulnerabilities may lead to unauthorized access to user data, loss of user private data, service disruptions and reputation damage.
|
||||
|
||||
**Recommendation**: Third-party libraries should be kept up-to-date, applying patches to address publicly known vulnerabilities in a timely fashion.
|
||||
Monitoring and logging capabilities should also be in place to detect and respond to potential attacks.
|
||||
SLSA compliance may also be considered for further supply chain security hardening.
|
427
.github/copilot-instructions.md
vendored
427
.github/copilot-instructions.md
vendored
@@ -1,427 +0,0 @@
|
||||
# nvm Copilot Instructions
|
||||
|
||||
This document provides guidance for GitHub Copilot when working with the Node Version Manager (nvm) codebase.
|
||||
|
||||
## Overview
|
||||
|
||||
nvm is a version manager for Node.js, implemented as a POSIX-compliant function that works across multiple shells (sh, dash, bash, ksh, zsh). The codebase is primarily written in shell script and emphasizes portability and compatibility.
|
||||
|
||||
### Core Architecture
|
||||
|
||||
- **Main script**: `nvm.sh` - Contains all core functionality and the main `nvm()` function
|
||||
- **Installation script**: `install.sh` - Handles downloading and installing nvm itself
|
||||
- **Execution wrapper**: `nvm-exec` - Allows running commands with specific Node.js versions
|
||||
- **Bash completion**: `bash_completion` - Provides tab completion for bash users
|
||||
- **Tests**: Comprehensive test suite in `test/` directory using the [urchin](https://www.npmjs.com/package/urchin) test framework
|
||||
|
||||
## Key Files and Their Purposes
|
||||
|
||||
### `nvm.sh`
|
||||
The core functionality file containing:
|
||||
- Main `nvm()` function (starts around line 3000)
|
||||
- All internal helper functions (prefixed with `nvm_`)
|
||||
- Command implementations for install, use, ls, etc.
|
||||
- Shell compatibility logic
|
||||
- POSIX compliance utilities
|
||||
|
||||
### `install.sh`
|
||||
Handles nvm installation via curl/wget/git:
|
||||
- Downloads nvm from GitHub
|
||||
- Sets up directory structure
|
||||
- Configures shell integration
|
||||
- Supports both git clone and script download methods
|
||||
|
||||
### `nvm-exec`
|
||||
Simple wrapper script that:
|
||||
- Sources nvm.sh with `--no-use` flag
|
||||
- Switches to specified Node version via `NODE_VERSION` env var or `.nvmrc`
|
||||
- Executes the provided command with that Node version
|
||||
|
||||
## Top-Level nvm Commands and Internal Functions
|
||||
|
||||
### Core Commands
|
||||
|
||||
#### `nvm install [version]`
|
||||
- **Internal functions**: `nvm_install_binary()`, `nvm_install_source()`, `nvm_download_artifact()`
|
||||
- Downloads and installs specified Node.js version
|
||||
- Automatically `nvm use`s that version after installation
|
||||
- Supports LTS versions, version ranges, and built-in aliases (like `node`, `stable`) and user-defined aliases
|
||||
- Can install from binary or compile from source
|
||||
- When compiling from source, accepts additional arguments that are passed to the compilation task
|
||||
|
||||
#### `nvm use [version]`
|
||||
- **Internal functions**: `nvm_resolve_alias()`, `nvm_version_path()`, `nvm_change_path()`
|
||||
- Switches current shell to use specified Node.js version
|
||||
- Updates PATH environment variable
|
||||
- Supports `.nvmrc` file integration
|
||||
|
||||
#### `nvm ls [pattern]`
|
||||
- **Internal functions**: `nvm_ls()`, `nvm_tree_contains_path()`
|
||||
- Lists installed Node.js versions
|
||||
- Supports pattern matching and filtering
|
||||
- Shows current version and aliases
|
||||
|
||||
#### `nvm ls-remote [pattern]`
|
||||
- **Internal functions**: `nvm_ls_remote()`, `nvm_download()`, `nvm_ls_remote_index_tab()`
|
||||
- Lists available Node.js versions from nodejs.org and iojs.org, or the env-var-configured mirrors
|
||||
- Supports LTS filtering and pattern matching
|
||||
- Downloads version index on-demand
|
||||
|
||||
#### `nvm alias [name] [version]`
|
||||
- **Internal functions**: `nvm_alias()`, `nvm_alias_path()`
|
||||
- Creates text files containing the mapped version, named as the alias name
|
||||
- Special aliases: `default`, `node`, `iojs`, `stable`, `unstable` (note: `stable` and `unstable` are deprecated, from node's pre-v1 release plan)
|
||||
- Stored in `$NVM_DIR/alias/` directory
|
||||
|
||||
#### `nvm current`
|
||||
- **Internal functions**: `nvm_ls_current()`
|
||||
- Shows currently active Node.js version
|
||||
- Returns "system" if using system Node.js
|
||||
|
||||
#### `nvm which [version]`
|
||||
- **Internal functions**: `nvm_version_path()`, `nvm_resolve_alias()`
|
||||
- Shows path to specified Node.js version
|
||||
- Resolves aliases and version strings
|
||||
|
||||
### Utility Commands
|
||||
|
||||
#### `nvm cache clear|dir`
|
||||
- Cache management for downloaded binaries and source code
|
||||
- Clears or shows cache directory path
|
||||
|
||||
#### `nvm debug`
|
||||
- Diagnostic information for troubleshooting
|
||||
- Shows environment, tool versions, and paths
|
||||
|
||||
#### `nvm deactivate`
|
||||
- Removes nvm modifications from current shell
|
||||
- Restores original PATH
|
||||
|
||||
#### `nvm unload`
|
||||
- Completely removes nvm from shell environment
|
||||
- Unsets all nvm functions and variables
|
||||
|
||||
### Internal Function Categories
|
||||
|
||||
#### Version Resolution
|
||||
- `nvm_resolve_alias()` - Resolves aliases to version numbers
|
||||
- `nvm_version()` - Finds best matching local version
|
||||
- `nvm_remote_version()` - Finds best matching remote version
|
||||
- `nvm_normalize_version()` - Standardizes version strings
|
||||
- `nvm_version_greater()` - Compares version numbers
|
||||
- `nvm_version_greater_than_or_equal_to()` - Version comparison with equality
|
||||
- `nvm_get_latest()` - Gets latest version from a list
|
||||
|
||||
#### Installation Helpers
|
||||
- `nvm_install_binary()` - Downloads and installs precompiled binaries
|
||||
- `nvm_install_source()` - Compiles Node.js from source
|
||||
- `nvm_download_artifact()` - Downloads tarballs or binaries
|
||||
- `nvm_compute_checksum()` - Verifies download integrity
|
||||
- `nvm_checksum()` - Checksum verification wrapper
|
||||
- `nvm_get_mirror()` - Gets appropriate download mirror
|
||||
- `nvm_get_arch()` - Determines system architecture
|
||||
|
||||
#### Path Management
|
||||
- `nvm_change_path()` - Updates PATH for version switching
|
||||
- `nvm_strip_path()` - Removes nvm paths from PATH
|
||||
- `nvm_version_path()` - Gets installation path for version
|
||||
- `nvm_version_dir()` - Gets version directory name
|
||||
- `nvm_prepend_path()` - Safely prepends to PATH
|
||||
|
||||
#### Shell Detection and Compatibility
|
||||
- `nvm_is_zsh()` - Shell detection for zsh
|
||||
- `nvm_is_iojs_version()` - Checks if version is io.js
|
||||
- `nvm_get_os()` - Operating system detection
|
||||
- `nvm_supports_source_options()` - Checks if shell supports source options
|
||||
|
||||
#### Network and Remote Operations
|
||||
- `nvm_download()` - Generic download function
|
||||
- `nvm_ls_remote()` - Lists remote versions
|
||||
- `nvm_ls_remote_iojs()` - Lists remote io.js versions
|
||||
- `nvm_ls_remote_index_tab()` - Parses remote version index
|
||||
|
||||
#### Utility Functions
|
||||
- `nvm_echo()`, `nvm_err()` - Output functions
|
||||
- `nvm_has()` - Checks if command exists
|
||||
- `nvm_sanitize_path()` - Cleans sensitive data from paths
|
||||
- `nvm_die_on_prefix()` - Validates npm prefix settings
|
||||
- `nvm_ensure_default_set()` - Ensures default alias is set
|
||||
- `nvm_auto()` - Automatic version switching from .nvmrc
|
||||
|
||||
#### Alias Management
|
||||
- `nvm_alias()` - Creates or lists aliases
|
||||
- `nvm_alias_path()` - Gets path to alias file
|
||||
- `nvm_unalias()` - Removes aliases
|
||||
- `nvm_resolve_local_alias()` - Resolves local aliases
|
||||
|
||||
#### Listing and Display
|
||||
- `nvm_ls()` - Lists local versions
|
||||
- `nvm_ls_current()` - Shows current version
|
||||
- `nvm_tree_contains_path()` - Checks if path is in nvm tree
|
||||
- `nvm_format_version()` - Formats version display
|
||||
|
||||
## Running Tests
|
||||
|
||||
### Test Framework
|
||||
nvm uses the [urchin](https://www.npmjs.com/package/urchin) test framework for shell script testing.
|
||||
|
||||
### Test Structure
|
||||
```
|
||||
test/
|
||||
├── fast/ # Quick unit tests
|
||||
├── slow/ # Integration tests
|
||||
├── sourcing/ # Shell sourcing tests
|
||||
├── install_script/ # Installation script tests
|
||||
├── installation_node/ # Node installation tests
|
||||
├── installation_iojs/ # io.js installation tests
|
||||
└── common.sh # Shared test utilities
|
||||
```
|
||||
|
||||
### Running Tests
|
||||
|
||||
#### Install Dependencies
|
||||
```bash
|
||||
npm install # Installs urchin, semver, and replace tools
|
||||
```
|
||||
|
||||
#### Run All Tests
|
||||
```bash
|
||||
npm test # Runs tests in current shell (sh, bash, dash, zsh, ksh)
|
||||
make test # Runs tests in all supported shells (sh, bash, dash, zsh, ksh)
|
||||
make test-sh # Runs tests only in sh
|
||||
make test-bash # Runs tests only in bash
|
||||
make test-dash # Runs tests only in dash
|
||||
make test-zsh # Runs tests only in zsh
|
||||
make test-ksh # Runs tests only in ksh
|
||||
```
|
||||
|
||||
#### Run Specific Test Suites
|
||||
```bash
|
||||
make TEST_SUITE=fast test # Only fast tests
|
||||
make TEST_SUITE=slow test # Only slow tests
|
||||
make SHELLS=bash test # Only bash shell
|
||||
```
|
||||
|
||||
#### Individual Test Execution
|
||||
```bash
|
||||
./test/fast/Unit\ tests/nvm_get_arch # Run single test (WARNING: This will exit/terminate your current shell session)
|
||||
./node_modules/.bin/urchin test/fast/ # Run fast test suite
|
||||
./node_modules/.bin/urchin 'test/fast/Unit tests/nvm_get_arch' # Run single test safely without shell termination
|
||||
./node_modules/.bin/urchin test/slow/ # Run slow test suite
|
||||
./node_modules/.bin/urchin test/sourcing/ # Run sourcing test suite
|
||||
```
|
||||
|
||||
### Test Writing Guidelines
|
||||
- Tests should work across all supported shells (sh, bash, dash, zsh, ksh)
|
||||
- Define and use a `die()` function for test failures
|
||||
- Clean up after tests in cleanup functions
|
||||
- Mock external dependencies when needed
|
||||
- Place mocks in `test/mocks/` directory
|
||||
- Mock files should only be updated by the existing `update_test_mocks.sh` script, and any new mocks must be added to this script
|
||||
|
||||
## Shell Environment Setup
|
||||
|
||||
### Supported Shells
|
||||
- **bash** - Full feature support
|
||||
- **zsh** - Full feature support
|
||||
- **dash** - Basic POSIX support
|
||||
- **sh** - Basic POSIX support
|
||||
- **ksh** - Limited support (experimental)
|
||||
|
||||
### Installing Shell Environments
|
||||
|
||||
#### Ubuntu/Debian
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install bash zsh dash ksh
|
||||
# sh is typically provided by dash or bash and is available by default
|
||||
```
|
||||
|
||||
#### macOS
|
||||
```bash
|
||||
# bash and zsh are available by default, bash is not the default shell for new user accounts
|
||||
# Install other shells via Homebrew
|
||||
brew install dash ksh
|
||||
# For actual POSIX sh (not bash), install mksh which provides a true POSIX sh
|
||||
brew install mksh
|
||||
```
|
||||
|
||||
#### Manual Shell Testing
|
||||
```bash
|
||||
# Test in specific shell
|
||||
bash -c "source nvm.sh && nvm --version"
|
||||
zsh -c "source nvm.sh && nvm --version"
|
||||
dash -c ". nvm.sh && nvm --version"
|
||||
sh -c ". nvm.sh && nvm --version" # On macOS: mksh -c ". nvm.sh && nvm --version"
|
||||
ksh -c ". nvm.sh && nvm --version"
|
||||
```
|
||||
|
||||
### Shell-Specific Considerations
|
||||
- **zsh**: Requires basically any non-default zsh option to be temporarily unset to restore POSIX compliance
|
||||
- **dash**: Limited feature set, avoid bash-specific syntax
|
||||
- **ksh**: Some features may not work, primarily for compatibility testing
|
||||
|
||||
## CI Environment Details
|
||||
|
||||
### GitHub Actions Workflows
|
||||
|
||||
#### `.github/workflows/tests.yml`
|
||||
- Runs test suite across multiple shells and test suites
|
||||
- Uses `script` command for proper TTY simulation
|
||||
- Matrix strategy covers shell × test suite combinations
|
||||
- Excludes install_script tests from non-bash shells
|
||||
|
||||
#### `.github/workflows/shellcheck.yml`
|
||||
- Lints all shell scripts using shellcheck
|
||||
- Tests against multiple shell targets (bash, sh, dash, ksh)
|
||||
- Note: zsh is not included due to [shellcheck limitations](https://github.com/koalaman/shellcheck/issues/809)
|
||||
- Uses Homebrew to install latest shellcheck version
|
||||
|
||||
#### `.github/workflows/lint.yml`
|
||||
- Runs additional linting and formatting checks
|
||||
- Validates documentation and code style
|
||||
|
||||
### Travis CI (Legacy)
|
||||
- Configured in `.travis.yml`
|
||||
- Tests on multiple Ubuntu versions
|
||||
- Installs shell environments via apt packages
|
||||
|
||||
### CI Test Execution
|
||||
```bash
|
||||
# Simulate CI environment locally
|
||||
unset TRAVIS_BUILD_DIR # Disable Travis-specific logic
|
||||
unset GITHUB_ACTIONS # Disable GitHub Actions logic
|
||||
make test
|
||||
```
|
||||
|
||||
## Setting Up shellcheck Locally
|
||||
|
||||
### Installation
|
||||
|
||||
#### macOS (Homebrew)
|
||||
```bash
|
||||
brew install shellcheck
|
||||
```
|
||||
|
||||
#### Ubuntu/Debian
|
||||
```bash
|
||||
sudo apt-get install shellcheck
|
||||
```
|
||||
|
||||
#### From Source
|
||||
```bash
|
||||
# Download from https://github.com/koalaman/shellcheck/releases
|
||||
wget https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz
|
||||
tar -xf shellcheck-latest.linux.x86_64.tar.xz
|
||||
sudo cp shellcheck-latest/shellcheck /usr/local/bin/
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
#### Lint Main Files
|
||||
```bash
|
||||
shellcheck -s bash nvm.sh
|
||||
shellcheck -s bash install.sh
|
||||
shellcheck -s bash nvm-exec
|
||||
shellcheck -s bash bash_completion
|
||||
```
|
||||
|
||||
#### Lint Across Shell Types
|
||||
```bash
|
||||
shellcheck -s sh nvm.sh # POSIX sh
|
||||
shellcheck -s bash nvm.sh # Bash extensions
|
||||
shellcheck -s dash nvm.sh # Dash compatibility
|
||||
shellcheck -s ksh nvm.sh # Ksh compatibility
|
||||
```
|
||||
|
||||
#### Common shellcheck Directives in nvm
|
||||
- `# shellcheck disable=SC2039` - Allow bash extensions in POSIX mode
|
||||
- `# shellcheck disable=SC2016` - Allow literal `$` in single quotes
|
||||
- `# shellcheck disable=SC2001` - Allow sed usage instead of parameter expansion
|
||||
- `# shellcheck disable=SC3043` - Allow `local` keyword (bash extension)
|
||||
|
||||
### Fixing shellcheck Issues
|
||||
1. **Quoting**: Always quote variables: `"${VAR}"` instead of `$VAR`
|
||||
2. **POSIX compliance**: Avoid bash-specific features in portable sections
|
||||
3. **Array usage**: Use `set --` for positional parameters instead of arrays, which are not supported in POSIX
|
||||
4. **Local variables**: Declared with `local FOO` and then initialized on the next line (the latter is for ksh support)
|
||||
|
||||
## Development Best Practices
|
||||
|
||||
### Code Style
|
||||
- Use 2-space indentation
|
||||
- Follow POSIX shell guidelines for portability
|
||||
- Prefix internal functions with `nvm_`
|
||||
- Use `nvm_echo` instead of `echo` for output
|
||||
- Use `nvm_err` for error messages
|
||||
|
||||
### Compatibility
|
||||
- Test changes across all supported shells
|
||||
- Avoid bash-specific features in core functionality
|
||||
- Use `nvm_is_zsh` to check when zsh-specific behavior is needed
|
||||
- Mock external dependencies in tests
|
||||
|
||||
### Performance
|
||||
- Cache expensive operations (like remote version lists)
|
||||
- Use local variables to avoid scope pollution
|
||||
- Minimize subprocess calls where possible
|
||||
- Implement lazy loading for optional features
|
||||
|
||||
### Debugging
|
||||
- Use `nvm debug` command for environment information
|
||||
- Enable verbose output with `set -x` during development
|
||||
- Test with `NVM_DEBUG=1` environment variable
|
||||
- Check `$NVM_DIR/.cache` for cached data issues
|
||||
|
||||
## Common Gotchas
|
||||
|
||||
1. **PATH modification**: nvm modifies PATH extensively; be careful with restoration
|
||||
2. **Shell sourcing**: nvm must be sourced, not executed as a script
|
||||
3. **Version resolution**: Aliases, partial versions, and special keywords interact complexly
|
||||
4. **Platform differences**: Handle differences between Linux, macOS, and other Unix systems
|
||||
5. **Network dependencies**: Many operations require internet access for version lists
|
||||
6. **Concurrent access**: Multiple shells can conflict when installing versions simultaneously
|
||||
|
||||
## Windows Support
|
||||
|
||||
nvm works on Windows via several compatibility layers:
|
||||
|
||||
### WSL2 (Windows Subsystem for Linux)
|
||||
- Full nvm functionality available
|
||||
- **Important**: Ensure you're using WSL2, not WSL1 - see [Microsoft's WSL2 installation guide](https://docs.microsoft.com/en-us/windows/wsl/install) for up-to-date instructions
|
||||
- Install Ubuntu or other Linux distribution from Microsoft Store
|
||||
- Follow Linux installation instructions within WSL2
|
||||
|
||||
### Cygwin
|
||||
- POSIX-compatible environment for Windows
|
||||
- Download Cygwin from [cygwin.com](https://www.cygwin.com/install.html) and run the installer
|
||||
- During installation, include these packages: bash, curl, git, tar, and wget
|
||||
- May require additional PATH configuration
|
||||
|
||||
### Git Bash (MSYS2)
|
||||
- Comes with Git for Windows
|
||||
- Limited functionality compared to full Linux environment
|
||||
- Some features may not work due to path translation issues, including:
|
||||
- Binary extraction paths may be incorrectly translated
|
||||
- Symlink creation may fail
|
||||
- Some shell-specific features may behave differently
|
||||
- File permissions handling differs from Unix systems
|
||||
|
||||
### Setup Instructions for Windows
|
||||
|
||||
#### WSL2 (recommended)
|
||||
1. Install WSL2 using the official Microsoft guide: https://docs.microsoft.com/en-us/windows/wsl/install
|
||||
2. Install Ubuntu or preferred Linux distribution from Microsoft Store
|
||||
3. Follow standard Linux installation within WSL2
|
||||
|
||||
#### Git Bash
|
||||
1. Install Git for Windows (includes Git Bash) from https://git-scm.com/download/win
|
||||
2. Open Git Bash terminal
|
||||
3. Run nvm installation script
|
||||
|
||||
#### Cygwin
|
||||
1. Download and install Cygwin from https://www.cygwin.com/install.html
|
||||
2. Include bash, curl, git, tar, and wget packages during installation
|
||||
3. Run nvm installation in Cygwin terminal
|
||||
|
||||
This guide should help GitHub Copilot understand the nvm codebase structure, testing procedures, and development environment setup requirements.
|
BIN
.github/external-threat-actor.png
vendored
BIN
.github/external-threat-actor.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 134 KiB |
BIN
.github/insider-threat-actor-and-libs.png
vendored
BIN
.github/insider-threat-actor-and-libs.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 55 KiB |
86
.github/workflows/latest-npm.yml
vendored
86
.github/workflows/latest-npm.yml
vendored
@@ -1,86 +0,0 @@
|
||||
name: 'Tests: `nvm install-latest-npm`'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
latest: ${{ steps.set-matrix.outputs.requireds }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
iojs.org:443
|
||||
nodejs.org:443
|
||||
raw.githubusercontent.com:443
|
||||
- uses: ljharb/actions/node/matrix@main
|
||||
id: set-matrix
|
||||
with:
|
||||
versionsAsRoot: true
|
||||
type: majors
|
||||
preset: '>=1'
|
||||
|
||||
nodes:
|
||||
needs: [matrix]
|
||||
permissions:
|
||||
contents: read
|
||||
name: 'nvm install-latest-npm'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
|
||||
include:
|
||||
- node-version: "21"
|
||||
- node-version: "20.5"
|
||||
- node-version: "20.4"
|
||||
- node-version: "14.17"
|
||||
- node-version: "14.16"
|
||||
- node-version: "9.2"
|
||||
- node-version: "9.1"
|
||||
- node-version: "9.0"
|
||||
- node-version: "6.1"
|
||||
- node-version: "5.9"
|
||||
- node-version: "4.6"
|
||||
- node-version: "4.5"
|
||||
- node-version: "4.4"
|
||||
- node-version: "0.12"
|
||||
- node-version: "0.10"
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
iojs.org:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'install node'
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
skip-ls-check: true
|
||||
skip-install: true
|
||||
skip-latest-npm: true
|
||||
- run: npm --version
|
||||
- run: '. ./nvm.sh ; nvm install-latest-npm'
|
||||
name: 'nvm install-latest-npm'
|
||||
- run: npm --version
|
||||
|
||||
node:
|
||||
permissions:
|
||||
contents: none
|
||||
name: 'nvm install-latest-npm'
|
||||
needs: [nodes]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: true
|
72
.github/workflows/lint.yml
vendored
72
.github/workflows/lint.yml
vendored
@@ -1,72 +0,0 @@
|
||||
name: 'Tests: linting'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
eclint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'nvm install ${{ matrix.node-version }} && npm install'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: npm run eclint
|
||||
|
||||
dockerfile_lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
ghcr.io:443
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
pkg-containers.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'nvm install ${{ matrix.node-version }} && npm install'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: npm run dockerfile_lint
|
||||
|
||||
doctoc:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'nvm install ${{ matrix.node-version }} && npm install'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: npm run doctoc:check
|
||||
|
||||
test_naming:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
- uses: actions/checkout@v4
|
||||
- name: check tests filenames
|
||||
run: ./rename_test.sh --check
|
104
.github/workflows/nvm-install-test.yml
vendored
104
.github/workflows/nvm-install-test.yml
vendored
@@ -1,104 +0,0 @@
|
||||
name: 'Tests: nvm install with set -e'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: 'git ref to use'
|
||||
required: false
|
||||
default: 'HEAD'
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- id: matrix
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.ref }}" ]; then
|
||||
echo "matrix=\"[\"${{ github.event.inputs.ref }}\"]\"" >> $GITHUB_OUTPUT
|
||||
else
|
||||
TAGS="$((echo "HEAD" && git tag --sort=-v:refname --merged HEAD --format='%(refname:strip=2) %(creatordate:short)' | grep '^v' | while read tag date; do
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
timestamp=$(date -j -f "%Y-%m-%d" "$date" +%s)
|
||||
threshold=$(date -j -v-4y +%s)
|
||||
else
|
||||
timestamp=$(date -d "$date" +%s)
|
||||
threshold=$(date -d "4 years ago" +%s)
|
||||
fi
|
||||
if [ $timestamp -ge $threshold ]; then echo "$tag"; fi
|
||||
done) | xargs)"
|
||||
echo $TAGS
|
||||
TAGS_JSON=$(printf "%s\n" $TAGS | jq -R . | jq -sc .)
|
||||
echo "matrix=${TAGS_JSON}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
test:
|
||||
needs: [matrix]
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: ${{ matrix.ref == 'v0.40.0' }} # https://github.com/nvm-sh/nvm/issues/3405
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ref: ${{ fromJson(needs.matrix.outputs.matrix) }}
|
||||
has-nvmrc:
|
||||
- 'no nvmrc'
|
||||
- 'nvmrc'
|
||||
shell-level:
|
||||
- 1 shlvl
|
||||
- 2 shlvls
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: resolve HEAD to sha
|
||||
run: |
|
||||
if [ '${{ matrix.ref }}' = 'HEAD' ]; then
|
||||
REF="$(git rev-parse HEAD)"
|
||||
else
|
||||
REF="${{ matrix.ref }}"
|
||||
fi
|
||||
echo "resolved ref: ${REF}"
|
||||
echo "ref="$REF"" >> $GITHUB_ENV
|
||||
- run: echo $- # which options are set
|
||||
- run: echo node > .nvmrc
|
||||
if: ${{ matrix.has-nvmrc == 'nvmrc' }}
|
||||
- run: curl -I --compressed -v https://nodejs.org/dist/
|
||||
- name: 'install nvm'
|
||||
run: |
|
||||
set -e
|
||||
export NVM_INSTALL_VERSION="${ref}"
|
||||
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${ref}/install.sh" | bash
|
||||
- name: nvm --version
|
||||
run: |
|
||||
set +e
|
||||
. $NVM_DIR/nvm.sh && nvm --version
|
||||
- name: nvm install in 1 shell level, ${{ matrix.has-nvmrc }}
|
||||
if: ${{ matrix.shell-level == '1 shlvl' }}
|
||||
run: |
|
||||
set -ex
|
||||
. $NVM_DIR/nvm.sh
|
||||
echo nvm.sh sourced
|
||||
nvm --version
|
||||
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
|
||||
nvm install
|
||||
fi
|
||||
- name: nvm install in 2 shell levels, ${{ matrix.has-nvmrc }}
|
||||
if: ${{ matrix.shell-level == '2 shlvls' }}
|
||||
run: |
|
||||
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
|
||||
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version && nvm install"
|
||||
else
|
||||
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version"
|
||||
fi
|
||||
|
||||
finisher:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test]
|
||||
steps:
|
||||
- run: true
|
26
.github/workflows/rebase.yml
vendored
26
.github/workflows/rebase.yml
vendored
@@ -1,26 +0,0 @@
|
||||
name: Automatic Rebase
|
||||
|
||||
on: [pull_request_target]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
_:
|
||||
permissions:
|
||||
contents: write
|
||||
name: "Automatic Rebase"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
api.github.com:443
|
||||
github.com:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ljharb/rebase@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
39
.github/workflows/release.yml
vendored
39
.github/workflows/release.yml
vendored
@@ -1,39 +0,0 @@
|
||||
name: 'Tests: release process'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
api.github.com:443
|
||||
objects.githubusercontent.com:443
|
||||
raw.githubusercontent.com:443
|
||||
release-assets.githubusercontent.com:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "14"
|
||||
- run: npm install
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git fetch --unshallow --tags -f || git fetch --tags -f
|
||||
- name: Attempt `make release` process
|
||||
run: echo proceed | make TAG=99.99.99 release
|
||||
env:
|
||||
GIT_EDITOR: "sed -i '1 s/^/99.99.99 make release test/'"
|
||||
- name: Ensure tag is created
|
||||
run: git tag | grep v99.99.99
|
24
.github/workflows/require-allow-edits.yml
vendored
24
.github/workflows/require-allow-edits.yml
vendored
@@ -1,24 +0,0 @@
|
||||
name: Require “Allow Edits”
|
||||
|
||||
on: [pull_request_target]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
_:
|
||||
permissions:
|
||||
pull-requests: read
|
||||
name: "Require “Allow Edits”"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
api.github.com:443
|
||||
- uses: ljharb/require-allow-edits@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
56
.github/workflows/shellcheck.yml
vendored
56
.github/workflows/shellcheck.yml
vendored
@@ -1,56 +0,0 @@
|
||||
name: 'Tests: shellcheck'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
shellcheck_matrix:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shell:
|
||||
- bash
|
||||
- sh
|
||||
- dash
|
||||
- ksh
|
||||
file:
|
||||
- nvm.sh
|
||||
include:
|
||||
- shell: bash
|
||||
file: install.sh # only supported on bash
|
||||
- shell: bash
|
||||
file: bash_completion # only needed in bash/zsh
|
||||
- shell: bash
|
||||
file: nvm-exec # only runs in bash
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
ghcr.io:443
|
||||
github.com:443
|
||||
pkg-containers.githubusercontent.com:443
|
||||
formulae.brew.sh:443
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Homebrew
|
||||
uses: Homebrew/actions/setup-homebrew@master
|
||||
- name: Install latest shellcheck
|
||||
run: brew install shellcheck
|
||||
env:
|
||||
HOMEBREW_NO_ANALYTICS: 1
|
||||
- run: which shellcheck
|
||||
- run: shellcheck --version
|
||||
- name: Run shellcheck on ${{ matrix.file }}
|
||||
run: shellcheck -s ${{ matrix.shell }} ${{ matrix.file }}
|
||||
|
||||
shellcheck:
|
||||
permissions:
|
||||
contents: none
|
||||
needs: [shellcheck_matrix]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: true
|
80
.github/workflows/tests.yml
vendored
80
.github/workflows/tests.yml
vendored
@@ -1,80 +0,0 @@
|
||||
name: urchin tests
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
name: "tests"
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
exclude:
|
||||
- shell: sh
|
||||
suite: install_script
|
||||
- shell: dash
|
||||
suite: install_script
|
||||
- shell: zsh
|
||||
suite: install_script
|
||||
- shell: ksh
|
||||
suite: install_script
|
||||
suite:
|
||||
- install_script
|
||||
- sourcing
|
||||
- slow
|
||||
- installation_iojs
|
||||
shell:
|
||||
- sh
|
||||
- bash
|
||||
- dash
|
||||
- zsh
|
||||
# - ksh
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
registry.npmjs.org:443
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
iojs.org:443
|
||||
azure.archive.ubuntu.com:80
|
||||
packages.microsoft.com:443
|
||||
- uses: actions/checkout@v4
|
||||
- run: sudo apt-get update; sudo apt-get install ${{ matrix.shell }}
|
||||
if: matrix.shell == 'zsh' || matrix.shell == 'ksh'
|
||||
# zsh (https://github.com/actions/runner-images/issues/264) and ksh are not in the ubuntu image
|
||||
shell: bash
|
||||
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
|
||||
- run: curl --version
|
||||
- run: wget --version
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'npm install && version checks'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
skip-ls-check: true
|
||||
- run: npm ls urchin
|
||||
- run: npx which urchin
|
||||
- run: env
|
||||
- run: make TERM=xterm-256color TEST_SUITE="${{ matrix.suite }}" SHELL="${{ matrix.shell }}" URCHIN="$(npx which urchin)" test-${{ matrix.shell }}
|
||||
|
||||
nvm:
|
||||
permissions:
|
||||
contents: none
|
||||
name: 'all test suites, all shells'
|
||||
needs: [tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: true
|
41
.github/workflows/toc.yml
vendored
41
.github/workflows/toc.yml
vendored
@@ -1,41 +0,0 @@
|
||||
name: update readme TOC
|
||||
|
||||
on: [push]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
_:
|
||||
permissions:
|
||||
contents: write
|
||||
name: "update readme TOC"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v2
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
registry.npmjs.org:443
|
||||
api.github.com:443
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# https://github.com/actions/checkout/issues/217#issue-599945005
|
||||
# pulls all commits (needed for lerna / semantic release to correctly version)
|
||||
fetch-depth: "0"
|
||||
|
||||
# pulls all tags (needed for lerna / semantic release to correctly version)
|
||||
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: npm install
|
||||
- run: npm run doctoc
|
||||
- name: commit changes
|
||||
uses: ljharb/actions-js-build/commit@v3+amendpush
|
||||
with:
|
||||
amend: true
|
||||
force: true
|
216
.github/workflows/windows-npm.yml
vendored
216
.github/workflows/windows-npm.yml
vendored
@@ -1,216 +0,0 @@
|
||||
name: 'Tests on Windows: `nvm install`'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
NVM_INSTALL_GITHUB_REPO: ${{ github.repository }}
|
||||
NVM_INSTALL_VERSION: ${{ github.sha }}
|
||||
|
||||
jobs:
|
||||
msys_fail_install:
|
||||
# Default installation does not work due to npm_config_prefix set to C:\npm\prefix
|
||||
permissions:
|
||||
contents: none
|
||||
name: 'MSYS fail prefix nvm install'
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Retrieve nvm
|
||||
shell: bash
|
||||
run: |
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
|
||||
. "$HOME/.nvm/nvm.sh"
|
||||
! nvm install --lts
|
||||
|
||||
msys_matrix:
|
||||
permissions:
|
||||
contents: none
|
||||
name: 'MSYS nvm install'
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
npm-node-version:
|
||||
- '--lts'
|
||||
- '--default 12'
|
||||
- '--no-progress 10'
|
||||
steps:
|
||||
- name: Retrieve nvm
|
||||
shell: bash
|
||||
run: |
|
||||
unset npm_config_prefix
|
||||
if [ "${{ matrix.npm-node-version }}" = "--lts" ]; then
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
|
||||
else
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
|
||||
fi
|
||||
. "$HOME/.nvm/nvm.sh"
|
||||
nvm install ${{ matrix.npm-node-version }}
|
||||
|
||||
cygwin_matrix:
|
||||
continue-on-error: true
|
||||
permissions:
|
||||
contents: none
|
||||
name: 'Cygwin nvm install'
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Install Cygwin
|
||||
shell: bash
|
||||
run: |
|
||||
export SITE='https://mirror.clarkson.edu/cygwin/' # see https://archlinux.org/mirrors/clarkson.edu/1603/ for uptime status
|
||||
export SITE='https://mirrors.kernel.org/sourceware/cygwin/'
|
||||
export LOCALDIR="$(pwd)"
|
||||
export ROOTDIR="$USERPROFILE\\cygwin"
|
||||
export PACKAGES='bash,git,curl'
|
||||
|
||||
curl -fsSLo setup-x86_64.exe 'https://cygwin.com/setup-x86_64.exe'
|
||||
./setup-x86_64.exe --disable-buggy-antivirus -q -s "$SITE" -l "$LOCALDIR" -R "$ROOTDIR" -P "$PACKAGES"
|
||||
|
||||
cat >~/setup.sh <<EOM
|
||||
unset npm_config_prefix
|
||||
export NVM_INSTALL_GITHUB_REPO="$NVM_INSTALL_GITHUB_REPO"
|
||||
export NVM_INSTALL_VERSION="$NVM_INSTALL_VERSION"
|
||||
export HOME="$(cygpath -u "$USERPROFILE")"
|
||||
|
||||
echo "HOME is $HOME"
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
|
||||
ls -l $HOME/.nvm
|
||||
. "$HOME/.nvm/nvm.sh"
|
||||
nvm install --lts
|
||||
|
||||
nvm deactivate
|
||||
rm -rf "$HOME/.nvm/nvm.sh"
|
||||
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
|
||||
. "$HOME/.nvm/nvm.sh"
|
||||
nvm install 9
|
||||
EOM
|
||||
- name: Retrieve nvm
|
||||
shell: cmd
|
||||
run: |
|
||||
cd %USERPROFILE%\cygwin\bin
|
||||
bash.exe "%USERPROFILE%\setup.sh"
|
||||
|
||||
wsl_matrix:
|
||||
continue-on-error: true
|
||||
name: 'WSL nvm install'
|
||||
defaults:
|
||||
run:
|
||||
shell: wsl-bash {0}
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
wsl-distrib:
|
||||
- Debian
|
||||
# - Alpine # fails
|
||||
- Ubuntu-20.04
|
||||
- Ubuntu-18.04
|
||||
npm-node-version:
|
||||
- '--lts'
|
||||
- '21'
|
||||
- '18'
|
||||
- '16'
|
||||
- '14'
|
||||
- '12'
|
||||
- '10'
|
||||
exclude:
|
||||
- wsl-distrib: Ubuntu-18.04
|
||||
npm-node-version: '--lts'
|
||||
- wsl-distrib: Ubuntu-18.04
|
||||
npm-node-version: '21'
|
||||
- wsl-distrib: Ubuntu-18.04
|
||||
npm-node-version: '18'
|
||||
method:
|
||||
- ''
|
||||
- 'script'
|
||||
steps:
|
||||
- uses: Vampire/setup-wsl@v3
|
||||
with:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
|
||||
# see https://github.com/Vampire/setup-wsl/issues/76#issuecomment-3258201135
|
||||
- shell: 'wsl-bash {0}'
|
||||
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
||||
- uses: Vampire/setup-wsl@v3
|
||||
with:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
update: 'true'
|
||||
|
||||
- name: Retrieve nvm on WSL
|
||||
run: |
|
||||
if [ -z "${{ matrix.method }}" ]; then
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
|
||||
else
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash
|
||||
fi
|
||||
. "$HOME/.nvm/nvm.sh"
|
||||
nvm install ${{ matrix.npm-node-version }}
|
||||
node -v
|
||||
|
||||
wsl_matrix_unofficial:
|
||||
continue-on-error: true
|
||||
name: 'WSL nvm install'
|
||||
defaults:
|
||||
run:
|
||||
shell: wsl-bash {0}
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p
|
||||
NVM_NODEJS_ORG_MIRROR: https://unofficial-builds.nodejs.org/download/release
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
wsl-distrib:
|
||||
- Alpine
|
||||
npm-node-version:
|
||||
- '--lts'
|
||||
- '21'
|
||||
- '18'
|
||||
- '16'
|
||||
- '14'
|
||||
- '12'
|
||||
- '11'
|
||||
- '10'
|
||||
method:
|
||||
- ''
|
||||
- 'script'
|
||||
steps:
|
||||
- uses: Vampire/setup-wsl@v3
|
||||
with:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
|
||||
# see https://github.com/Vampire/setup-wsl/issues/76#issuecomment-3258201135
|
||||
- shell: 'wsl-bash {0}'
|
||||
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
||||
- uses: Vampire/setup-wsl@v3
|
||||
with:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
update: 'true'
|
||||
|
||||
- name: Retrieve nvm on WSL
|
||||
run: |
|
||||
if [ -z "${{ matrix.method }}" ]; then
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
|
||||
else
|
||||
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash
|
||||
fi
|
||||
. "$HOME/.nvm/nvm.sh"
|
||||
NVM_NODEJS_ORG_MIRROR=${{ env.NVM_NODEJS_ORG_MIRROR }} nvm install ${{ matrix.npm-node-version }}
|
||||
|
||||
nvm_windows:
|
||||
name: 'tests, on windows'
|
||||
permissions:
|
||||
contents: none
|
||||
needs: [wsl_matrix, wsl_matrix_unofficial, cygwin_matrix, msys_matrix, msys_fail_install]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: true
|
13
.gitignore
vendored
13
.gitignore
vendored
@@ -1,6 +1,5 @@
|
||||
# gitignore
|
||||
HEAD
|
||||
.cache
|
||||
src
|
||||
v*
|
||||
alias
|
||||
|
||||
@@ -8,19 +7,9 @@ alias
|
||||
test/bak
|
||||
.urchin.log
|
||||
.urchin_stdout
|
||||
test/**/test_output
|
||||
test/**/.nvmrc
|
||||
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
.DS_Store
|
||||
current
|
||||
/default-packages
|
||||
|
||||
# Only apps should have lockfiles
|
||||
npm-shrinkwrap.json
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
target/
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "test/fixtures/nvmrc"]
|
||||
path = test/fixtures/nvmrc
|
||||
url = git@github.com:nvm-sh/nvmrc.git
|
4
.npmignore
Normal file
4
.npmignore
Normal file
@@ -0,0 +1,4 @@
|
||||
src
|
||||
v*
|
||||
alias
|
||||
|
126
.travis.yml
126
.travis.yml
@@ -1,94 +1,42 @@
|
||||
language: generic
|
||||
dist: focal
|
||||
language: c # defaults to ruby
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- zsh
|
||||
# - ksh
|
||||
# - gcc-4.8
|
||||
# - g++-4.8
|
||||
|
||||
# https://gist.github.com/iedemam/9830045
|
||||
git:
|
||||
submodules: false
|
||||
|
||||
cache:
|
||||
ccache: true
|
||||
directories:
|
||||
- $TRAVIS_BUILD_DIR/.cache
|
||||
- $TRAVIS_BUILD_DIR/node_modules
|
||||
before_install:
|
||||
- sudo sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf
|
||||
- sudo update-ca-certificates -f
|
||||
|
||||
# https://gist.github.com/iedemam/9830045
|
||||
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
|
||||
- git submodule update --init --recursive
|
||||
|
||||
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
|
||||
- curl --version
|
||||
- wget --version
|
||||
- bash --version | head
|
||||
- zsh --version
|
||||
- dpkg -s dash | grep ^Version | awk '{print $2}'
|
||||
# install python
|
||||
- pyenv local 2.7.18 || pyenv install 2.7.18
|
||||
- pyenv local 2.7.18 || echo 'pyenv failed'
|
||||
- python -V
|
||||
apt_packages:
|
||||
- zsh
|
||||
- ksh
|
||||
install:
|
||||
- if [ -z "${SHELLCHECK-}" ]; then nvm install 16 && nvm unalias default && npm install && npm prune && npm ls urchin doctoc eclint dockerfile_lint; fi
|
||||
- (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*)
|
||||
- chmod +x /tmp/urchin/package/urchin
|
||||
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||
script:
|
||||
- if [ -n "${SHELL-}" ] && [ -n "${TEST_SUITE}" ]; then if [ "${TEST_SUITE}" = 'installation_iojs' ] || [ "${TEST_SUITE}" = 'xenial' ]; then travis_retry make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL ; else make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL; fi; fi
|
||||
before_cache:
|
||||
- if [ -n "$WITHOUT_CURL" ]; then sudo apt-get install curl -y ; fi
|
||||
jobs:
|
||||
include:
|
||||
- env: SHELL=bash TEST_SUITE=installation_node
|
||||
dist: xenial
|
||||
- env: SHELL=bash TEST_SUITE=installation_node WITHOUT_CURL=1
|
||||
dist: xenial
|
||||
- env: SHELL=sh TEST_SUITE=installation_node
|
||||
dist: xenial
|
||||
- env: SHELL=sh TEST_SUITE=installation_node WITHOUT_CURL=1
|
||||
dist: xenial
|
||||
- env: SHELL=dash TEST_SUITE=installation_node
|
||||
dist: xenial
|
||||
- env: SHELL=dash TEST_SUITE=installation_node WITHOUT_CURL=1
|
||||
dist: xenial
|
||||
- env: SHELL=zsh TEST_SUITE=installation_node
|
||||
dist: xenial
|
||||
- env: SHELL=zsh TEST_SUITE=installation_node WITHOUT_CURL=1
|
||||
dist: xenial
|
||||
#- env: SHELL=ksh TEST_SUITE=installation_node
|
||||
# dist: xenial
|
||||
#- env: SHELL=ksh TEST_SUITE=installation_node WITHOUT_CURL=1
|
||||
# dist: xenial
|
||||
- env: SHELL=bash TEST_SUITE=xenial
|
||||
dist: xenial
|
||||
- env: SHELL=sh TEST_SUITE=xenial
|
||||
dist: xenial
|
||||
- env: SHELL=dash TEST_SUITE=xenial
|
||||
dist: xenial
|
||||
- env: SHELL=zsh TEST_SUITE=xenial
|
||||
dist: xenial
|
||||
#- env: SHELL=ksh TEST_SUITE=xenial
|
||||
# dist: xenial
|
||||
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL
|
||||
env:
|
||||
global:
|
||||
- CXX=g++
|
||||
- CC=gcc
|
||||
- PATH="$(echo $PATH | sed 's/::/:/')"
|
||||
- PATH="/usr/lib/ccache/:$PATH"
|
||||
- NVM_DIR="${TRAVIS_BUILD_DIR}"
|
||||
matrix:
|
||||
- SHELL=sh TEST_SUITE=fast
|
||||
- SHELL=dash TEST_SUITE=fast
|
||||
- SHELL=bash TEST_SUITE=fast
|
||||
- SHELL=zsh TEST_SUITE=fast
|
||||
# - SHELL=ksh TEST_SUITE=fast
|
||||
- SHELL=sh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- SHELL=dash TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- SHELL=bash TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- SHELL=zsh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
# - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- SHELL=sh TEST_SUITE=install_script
|
||||
- SHELL=dash TEST_SUITE=install_script
|
||||
- SHELL=bash TEST_SUITE=install_script
|
||||
- SHELL=zsh TEST_SUITE=install_script
|
||||
# - SHELL=ksh TEST_SUITE=install_script
|
||||
- SHELL=sh TEST_SUITE=fast
|
||||
- SHELL=dash TEST_SUITE=fast
|
||||
- SHELL=bash TEST_SUITE=fast
|
||||
- SHELL=zsh TEST_SUITE=fast
|
||||
# - SHELL=ksh TEST_SUITE=fast
|
||||
- SHELL=sh TEST_SUITE=slow
|
||||
- SHELL=dash TEST_SUITE=slow
|
||||
- SHELL=bash TEST_SUITE=slow
|
||||
- SHELL=zsh TEST_SUITE=slow
|
||||
# - SHELL=ksh TEST_SUITE=slow
|
||||
- SHELL=sh TEST_SUITE=sourcing
|
||||
- SHELL=dash TEST_SUITE=sourcing
|
||||
- SHELL=bash TEST_SUITE=sourcing
|
||||
- SHELL=zsh TEST_SUITE=sourcing
|
||||
# - SHELL=ksh TEST_SUITE=sourcing
|
||||
- SHELL=sh TEST_SUITE=installation
|
||||
- SHELL=sh TEST_SUITE=installation WITHOUT_CURL=1
|
||||
- SHELL=dash TEST_SUITE=installation
|
||||
- SHELL=dash TEST_SUITE=installation WITHOUT_CURL=1
|
||||
- SHELL=bash TEST_SUITE=installation
|
||||
- SHELL=bash TEST_SUITE=installation WITHOUT_CURL=1
|
||||
- SHELL=zsh TEST_SUITE=installation
|
||||
- SHELL=zsh TEST_SUITE=installation WITHOUT_CURL=1
|
||||
# - SHELL=ksh TEST_SUITE=installation
|
||||
# - SHELL=ksh TEST_SUITE=installation WITHOUT_CURL=1
|
||||
|
@@ -1,125 +0,0 @@
|
||||
# Code of Conduct
|
||||
|
||||
`nvm`, as a member project of the OpenJS Foundation, uses [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) as their code of conduct. The full text is included [below](#contributor-covenant-code-of-conduct) in English, and translations are available from the Contributor Covenant organisation:
|
||||
|
||||
- [contributor-covenant.org/translations](https://www.contributor-covenant.org/translations)
|
||||
- [github.com/ContributorCovenant](https://github.com/ContributorCovenant/contributor_covenant/tree/release/content/version/2/1)
|
||||
|
||||
Refer to the sections on reporting and escalation in this document for the specific emails that can be used to report and escalate issues.
|
||||
|
||||
## Reporting
|
||||
|
||||
### Project Spaces
|
||||
|
||||
For reporting issues in spaces related to `nvm` please use the email `ljharb@gmail.com`. `nvm` handles CoC issues related to the spaces that it maintains. Projects maintainers commit to:
|
||||
|
||||
- maintain the confidentiality with regard to the reporter of an incident
|
||||
- to participate in the path for escalation as outlined in the section on Escalation when required.
|
||||
|
||||
### Foundation Spaces
|
||||
|
||||
For reporting issues in spaces managed by the OpenJS Foundation, for example, repositories within the OpenJS organization, use the email `report@lists.openjsf.org`.
|
||||
The Cross Project Council (CPC) is responsible for managing these reports and commits to:
|
||||
|
||||
- maintain the confidentiality with regard to the reporter of an incident
|
||||
- to participate in the path for escalation as outlined in the section on Escalation when required.
|
||||
|
||||
## Escalation
|
||||
|
||||
The OpenJS Foundation maintains a Code of Conduct Panel (CoCP).
|
||||
This is a foundation-wide team established to manage escalation when a reporter believes that a report to a member project or the CPC has not been properly handled.
|
||||
In order to escalate to the CoCP send an email to `coc-escalation@lists.openjsf.org`.
|
||||
|
||||
For more information, refer to the full [Code of Conduct governance document](https://github.com/openjs-foundation/cross-project-council/blob/HEAD/CODE_OF_CONDUCT.md).
|
||||
|
||||
---
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [@ljharb](ljharb@gmail.com).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
124
CONTRIBUTING.md
124
CONTRIBUTING.md
@@ -1,123 +1,15 @@
|
||||
# Contributing
|
||||
Thanks for contributing to `nvm`!
|
||||
|
||||
:+1::tada: First off, thanks for taking the time to contribute to `nvm`! :tada::+1:
|
||||
|
||||
We love pull requests and issues, they're our favorite.
|
||||
|
||||
The following is a set of guidelines for contributing to `nvm` managed by [@LJHarb](https://github.com/ljharb), which is hosted on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
|
||||
We love pull requests, they're our favorite.
|
||||
|
||||
However, before submitting, please review the following:
|
||||
|
||||
# How Can I Contribute?
|
||||
- Please include tests. Changes with tests will be merged very quickly.
|
||||
- Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also.
|
||||
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
|
||||
- Any time you make a change to your PR, please rebase freshly on top of master. Nobody likes merge commits.
|
||||
|
||||
There are lots of ways to get involved. Here are some suggestions of things we'd love some help with.
|
||||
Even if you don't have all of these items covered, please still feel free to submit a PR! Someone else may be inspired and volunteer to complete it for you.
|
||||
|
||||
## Resolving existing issues
|
||||
Thanks again!
|
||||
|
||||
You can consider helping out with issues already requiring attention - look for a "help wanted" label.
|
||||
|
||||
### How Do I Submit a (Good) Bug Report? :bug:
|
||||
|
||||
Explain the problem and include additional details to help maintainers reproduce the problem:
|
||||
|
||||
* **Use a clear and descriptive title** for the issue to identify the problem.
|
||||
|
||||
* **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining which command exactly you used in the terminal. When listing steps, **don't just say what you did, but explain how you did it**. For example, if you moved the cursor to the end of a line, explain if you used the mouse, or a keyboard shortcut or a command, and if so which one?
|
||||
* **Provide specific examples to demonstrate the steps**. Include links to files or Github projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines).
|
||||
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
|
||||
* **Explain which behavior you expected to see instead and why.**
|
||||
* **Provide as much context as possible** in order to help others verify and ultimately fix the issue. This includes giving us as much details as possible about your environment, so we can more easily confirm the problem.
|
||||
|
||||
## Documentation
|
||||
|
||||
We are happy to welcome contributions from anyone willing to improve documentation by adding missing information or making it more consistent and coherent.
|
||||
|
||||
# Dev Environment
|
||||
|
||||
Please refer to the [README](README.md) for complete instructions how to install, update, as well as troubleshoot `nvm` in your environment depending on your Operating System.
|
||||
|
||||
# Style Guide / Coding conventions
|
||||
|
||||
### Pull requests
|
||||
|
||||
#### Before creating a pull request
|
||||
|
||||
- Please include tests. Changes with tests will be merged very quickly.
|
||||
- Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also.
|
||||
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
|
||||
- Any time you make a change to your PR, please rebase freshly on top of the default branch. Nobody likes merge commits.
|
||||
|
||||
Even if you don't have all of these items covered, please still feel free to submit a PR/issue! Someone else may be inspired and volunteer to complete it for you.
|
||||
|
||||
#### How to create a pull request
|
||||
|
||||
Create a new branch
|
||||
|
||||
```
|
||||
git checkout -b issue1234
|
||||
```
|
||||
|
||||
Commit the changes to your branch, including a coherent commit message that follows our [standards](#commit-messages)
|
||||
|
||||
```
|
||||
git commit -a
|
||||
```
|
||||
|
||||
Before sending the pull request, make sure your code is running on the latest available code by rebasing onto the upstream source
|
||||
|
||||
```
|
||||
git fetch upstream
|
||||
git rebase upstream/main
|
||||
```
|
||||
|
||||
Verify your changes
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
Push your changes
|
||||
|
||||
```
|
||||
git push origin issue1234
|
||||
```
|
||||
|
||||
Send the [pull request](https://docs.github.com/en/pull-requests), make requested changes, and get merged.
|
||||
|
||||
### Commit Messages
|
||||
|
||||
* Limit the first line of the commit message (message summary) to 72 characters or less.
|
||||
* Use the present tense ("Add feature" not "Added feature") and imperative mood ("Move cursor to..." not "Moves cursor to...") when providing a description of what you did.
|
||||
* If your PR addresses an issue, reference it in the body of the commit message.
|
||||
* See the rest of the conventions [here](https://gist.github.com/ljharb/772b0334387a4bee89af24183114b3c7)
|
||||
|
||||
#### Commit message example
|
||||
|
||||
```
|
||||
[Tag]: Short description of what you did
|
||||
|
||||
Longer description here if necessary
|
||||
|
||||
Fixes #1234
|
||||
```
|
||||
|
||||
> **Note:** Add co-authors to your commit message for commits with multiple authors
|
||||
|
||||
```
|
||||
Co-authored-by: Name Here <email@here>
|
||||
```
|
||||
|
||||
|
||||
# Code of Conduct
|
||||
[Code of Conduct](https://github.com/nvm-sh/nvm/blob/HEAD/CODE_OF_CONDUCT.md)
|
||||
|
||||
# Where can I ask for help?
|
||||
If you have any questions, please contact [@LJHarb](mailto:ljharb@gmail.com).
|
||||
|
||||
# Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
- The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
|
||||
- The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
|
||||
- The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
|
||||
- I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.
|
||||
|
112
Dockerfile
112
Dockerfile
@@ -1,112 +0,0 @@
|
||||
# Dockerized nvm development environment
|
||||
#
|
||||
# This Dockerfile is for building nvm development environment only,
|
||||
# not for any distribution/production usage.
|
||||
#
|
||||
# Please note that it'll use about 1.2 GB disk space and about 15 minutes to
|
||||
# build this image, it depends on your hardware.
|
||||
|
||||
FROM ubuntu:22.04
|
||||
LABEL maintainer="Peter Dave Hello <hsu@peterdavehello.org>"
|
||||
LABEL name="nvm-dev-env"
|
||||
LABEL version="latest"
|
||||
|
||||
# Set the SHELL to bash with pipefail option
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Prevent dialog during apt install
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# ShellCheck version
|
||||
ENV SHELLCHECK_VERSION=0.7.0
|
||||
|
||||
# Pick a Ubuntu apt mirror site for better speed
|
||||
# ref: https://launchpad.net/ubuntu/+archivemirrors
|
||||
ENV UBUNTU_APT_SITE ubuntu.cs.utah.edu
|
||||
|
||||
# Replace origin apt package site with the mirror site
|
||||
RUN sed -E -i "s/([a-z]+.)?archive.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
|
||||
RUN sed -i "s/security.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
|
||||
|
||||
# Install apt packages
|
||||
RUN apt update && \
|
||||
apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" && \
|
||||
apt install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
|
||||
coreutils \
|
||||
util-linux \
|
||||
bsdutils \
|
||||
file \
|
||||
openssl \
|
||||
libssl-dev \
|
||||
locales \
|
||||
ca-certificates \
|
||||
ssh \
|
||||
wget \
|
||||
patch \
|
||||
sudo \
|
||||
htop \
|
||||
dstat \
|
||||
vim \
|
||||
tmux \
|
||||
curl \
|
||||
git \
|
||||
jq \
|
||||
zsh \
|
||||
ksh \
|
||||
gcc \
|
||||
g++ \
|
||||
xz-utils \
|
||||
build-essential \
|
||||
bash-completion && \
|
||||
apt-get clean
|
||||
|
||||
RUN wget https://github.com/koalaman/shellcheck/releases/download/v$SHELLCHECK_VERSION/shellcheck-v$SHELLCHECK_VERSION.linux.x86_64.tar.xz -O- | \
|
||||
tar xJvf - shellcheck-v$SHELLCHECK_VERSION/shellcheck && \
|
||||
mv shellcheck-v$SHELLCHECK_VERSION/shellcheck /bin && \
|
||||
rmdir shellcheck-v$SHELLCHECK_VERSION
|
||||
RUN shellcheck -V
|
||||
|
||||
# Set locale
|
||||
RUN locale-gen en_US.UTF-8
|
||||
|
||||
# Print tool versions
|
||||
RUN bash --version | head -n 1
|
||||
RUN zsh --version
|
||||
RUN ksh --version || true
|
||||
RUN dpkg -s dash | grep ^Version | awk '{print $2}'
|
||||
RUN git --version
|
||||
RUN curl --version
|
||||
RUN wget --version
|
||||
|
||||
# Add user "nvm" as non-root user
|
||||
RUN useradd -ms /bin/bash nvm
|
||||
|
||||
# Copy and set permission for nvm directory
|
||||
COPY . /home/nvm/.nvm/
|
||||
RUN chown nvm:nvm -R "/home/nvm/.nvm"
|
||||
|
||||
# Set sudoer for "nvm"
|
||||
RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
||||
|
||||
# Switch to user "nvm" from now
|
||||
USER nvm
|
||||
|
||||
# Create a script file sourced by both interactive and non-interactive bash shells
|
||||
ENV BASH_ENV /home/nvm/.bash_env
|
||||
RUN touch "$BASH_ENV"
|
||||
RUN echo '. "$BASH_ENV"' >> "$HOME/.bashrc"
|
||||
|
||||
# nvm
|
||||
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> "$BASH_ENV"
|
||||
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "$BASH_ENV"
|
||||
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$BASH_ENV"
|
||||
|
||||
# nodejs and tools
|
||||
RUN nvm install node
|
||||
RUN npm install -g doctoc urchin eclint dockerfile_lint
|
||||
RUN npm install --prefix "$HOME/.nvm/"
|
||||
|
||||
# Set WORKDIR to nvm directory
|
||||
WORKDIR /home/nvm/.nvm
|
||||
|
||||
ENTRYPOINT ["/bin/bash"]
|
@@ -1,10 +0,0 @@
|
||||
# `nvm` Project Governance
|
||||
|
||||
## Maintainers
|
||||
- [@ljharb](https://github.com/ljharb)
|
||||
|
||||
Maintainers are responsible for issue/PR triage, feature additions, maintenance, bugfixes, security fixes, releases, promoting existing contributors to maintainers, managing repo and CI configuration, etc.
|
||||
|
||||
## Contributors
|
||||
|
||||
Anyone who contributes code or content or time, via issues or pull requests or otherwise. Contributors do not have any additional permissions on the project.
|
@@ -1,8 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010 Tim Caswell
|
||||
|
||||
Copyright (c) 2014 Jordan Harband
|
||||
Copyright (c) 2010-2014 Tim Caswell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
@@ -20,3 +18,4 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
46
Makefile
46
Makefile
@@ -15,7 +15,7 @@ ifeq ($(findstring /,$(URCHIN)),) # urchin path was NOT passed in.
|
||||
UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS)))
|
||||
endif
|
||||
# The files that need updating when incrementing the version number.
|
||||
VERSIONED_FILES := nvm.sh install.sh README.md package.json
|
||||
VERSIONED_FILES := nvm.sh install.sh README.markdown package.json
|
||||
# Define all shells to test with. Can be overridden with `make SHELLS=... <target>`.
|
||||
SHELLS := sh bash dash zsh # ksh (#574)
|
||||
# Generate 'test-<shell>' target names from specified shells.
|
||||
@@ -40,14 +40,10 @@ list:
|
||||
# Note that preexisting NVM_* variables are unset to avoid interfering with tests, except when running the Travis tests (where NVM_DIR must be passed in and the env. is assumed to be pristine).
|
||||
.PHONY: $(SHELL_TARGETS)
|
||||
$(SHELL_TARGETS):
|
||||
@shell='$@'; shell=$${shell##*-}; \
|
||||
which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
|
||||
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
|
||||
[ -z "$$TRAVIS_BUILD_DIR" ] && [ -z "$$GITHUB_ACTIONS" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \
|
||||
for suite in $(TEST_SUITE); do \
|
||||
echo "Running test suite: $$suite"; \
|
||||
$(URCHIN) -f -s $$shell test/$$suite || exit; \
|
||||
done
|
||||
@shell='$@'; shell=$${shell##*-}; which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
|
||||
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
|
||||
[ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \
|
||||
for suite in $(TEST_SUITE); do $(URCHIN) -f -s $$shell test/$$suite || exit; done
|
||||
|
||||
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
|
||||
.PHONY: test
|
||||
@@ -59,14 +55,6 @@ ifndef TAG
|
||||
$(error Please invoke with `make TAG=<new-version> release`, where <new-version> is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number)
|
||||
endif
|
||||
|
||||
# Ensures there are version tags in repository
|
||||
.PHONY: _ensure-current-version
|
||||
|
||||
_ensure-current-version:
|
||||
ifeq ($(shell git tag),$(printf ''))
|
||||
@git fetch --tags
|
||||
endif
|
||||
|
||||
# Ensures that the git workspace is clean.
|
||||
.PHONY: _ensure-clean
|
||||
_ensure-clean:
|
||||
@@ -74,16 +62,16 @@ _ensure-clean:
|
||||
|
||||
# Makes a release; invoke with `make TAG=<versionOrIncrementSpec> release`.
|
||||
.PHONY: release
|
||||
release: _ensure-tag _ensure-clean _ensure-current-version
|
||||
release: _ensure-tag _ensure-clean
|
||||
@old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \
|
||||
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
|
||||
if printf "$$new_ver" | grep -q '^[0-9]'; then \
|
||||
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
|
||||
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
|
||||
else \
|
||||
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
|
||||
fi; \
|
||||
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
|
||||
replace "$$old_ver" "$$new_ver" $(VERSIONED_FILES) && \
|
||||
git commit -m "v$$new_ver" $(VERSIONED_FILES) && \
|
||||
git tag -a "v$$new_ver"
|
||||
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
|
||||
if printf "$$new_ver" | grep -q '^[0-9]'; then \
|
||||
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
|
||||
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
|
||||
else \
|
||||
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
|
||||
fi; \
|
||||
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
|
||||
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
|
||||
git commit -m "v$$new_ver" $(VERSIONED_FILES) && \
|
||||
git tag -a -m "v$$new_ver" "v$$new_ver"
|
||||
|
@@ -1,49 +0,0 @@
|
||||
# `nvm` Charter
|
||||
|
||||
nvm is a version manager for Node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and Windows WSL.
|
||||
|
||||
## Section 0: Guiding Principles
|
||||
|
||||
The `nvm` project is part of the [OpenJS Foundation][openjs foundation], which operates transparently, openly, collaboratively, and ethically. Project proposals, timelines, and status must not merely be open, but also easily visible to outsiders.
|
||||
|
||||
## Section 1: Scope
|
||||
|
||||
`nvm` is a node version manager, focused on making it easy to install and manage multiple Node.js versions. Any features related to managing the installation and removal of Node.js on any node-supported platform are potentially in scope.
|
||||
|
||||
## Section 2: Relationship with OpenJS Foundation CPC.
|
||||
|
||||
Technical leadership for the projects within the [OpenJS Foundation][openjs foundation] is delegated to the projects through their project charters by the [OpenJS Foundation Cross-Project Council](https://openjsf.org/about/governance/) (CPC). In the case of the `nvm` project, it is delegated to the [`nvm` Maintainers](README.md#maintainers) (the “Maintainers”). The OpenJS Foundation's business leadership is the Board of Directors (the “Board”).
|
||||
|
||||
This `nvm` Charter reflects a carefully constructed balanced role for the Maintainers and the CPC in the governance of the OpenJS Foundation. The charter amendment process is for the Maintainers to propose changes using simple majority of the full Maintainers, the proposed changes being subject to review and approval by the CPC. The CPC may additionally make amendments to the project charter at any time, though the CPC will not interfere with day-to-day discussions, votes or meetings of the Maintainers.
|
||||
|
||||
### 2.1 Other Formal Project Relationships
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
## Section 3: `nvm`'s Maintainers Governing Body
|
||||
|
||||
`nvm` is governed by its [maintainers](README.md#maintainers).
|
||||
|
||||
## Section 4: Roles & Responsibilities
|
||||
|
||||
The roles and responsibilities of `nvm`'s Maintainers are described in [GOVERNANCE.md](./GOVERNANCE.md).
|
||||
|
||||
### Section 4.1 Project Operations & Management
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
### Section 4.2: Decision-making, Voting, and/or Elections
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
### Section 4.3: Other Project Roles
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
## Section 5: Definitions
|
||||
|
||||
- *Contributors*: contribute code or other artifacts, but do not have the right to commit to the codebase. Contributors work with the project’s maintainers to have code committed to the code base. A Contributor may be promoted to a Maintainer by the Maintainers. Contributors should rarely be encumbered by the Maintainers and never by the CPC or OpenJS Foundation Board.
|
||||
|
||||
- *Maintainers*: Contributors with any kind of decision-making authority in the project.
|
||||
|
||||
[openjs foundation]: https://openjsf.org
|
212
README.markdown
Normal file
212
README.markdown
Normal file
@@ -0,0 +1,212 @@
|
||||
# Node Version Manager [][3]
|
||||
|
||||
## Installation
|
||||
|
||||
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
||||
|
||||
Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are not supported nor developed by us:
|
||||
- [nvmw](https://github.com/hakobera/nvmw)
|
||||
- [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
||||
|
||||
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Two alternatives exist, which are not supported nor developed by us:
|
||||
- [nvm-fish-wrapper](https://github.com/passcod/nvm-fish-wrapper)
|
||||
- [nvm-fish](https://github.com/Alex7Kom/nvm-fish) (does not support iojs)
|
||||
|
||||
### Install script
|
||||
|
||||
To install you could use the [install script][2] using cURL:
|
||||
|
||||
curl https://raw.githubusercontent.com/creationix/nvm/v0.24.2/install.sh | bash
|
||||
|
||||
or Wget:
|
||||
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.24.2/install.sh | bash
|
||||
|
||||
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
|
||||
|
||||
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR`, and `PROFILE` variables.
|
||||
Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
|
||||
|
||||
<sub>*NB. The installer can use `git`, `curl`, or `wget` to download `nvm`, whatever is available.*</sub>
|
||||
|
||||
### Manual install
|
||||
|
||||
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in a folder called `nvm`.
|
||||
|
||||
Or if you have `git` installed, then just clone it, and check out the latest version:
|
||||
|
||||
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
|
||||
|
||||
To activate nvm, you need to source it from your shell:
|
||||
|
||||
source ~/.nvm/nvm.sh
|
||||
|
||||
I always add this line to my `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login.
|
||||
Often I also put in a line to use a specific version of node.
|
||||
|
||||
## Usage
|
||||
|
||||
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
||||
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied.
|
||||
|
||||
To download, compile, and install the latest v0.10.x release of node, do this:
|
||||
|
||||
nvm install 0.10
|
||||
|
||||
And then in any new shell just use the installed version:
|
||||
|
||||
nvm use 0.10
|
||||
|
||||
Or you can just run it:
|
||||
|
||||
nvm run 0.10 --version
|
||||
|
||||
Or, you can run any arbitrary command in a subshell with the desired version of node:
|
||||
|
||||
nvm exec 0.10 node --version
|
||||
|
||||
You can also get the path to the executable to where it was installed:
|
||||
|
||||
nvm which 0.10
|
||||
|
||||
In place of a version pointer like "0.10", you can use the special default aliases "stable" and "unstable":
|
||||
|
||||
nvm install stable
|
||||
nvm install unstable
|
||||
nvm use stable
|
||||
nvm run unstable --version
|
||||
|
||||
If you want to install [io.js](https://github.com/iojs/io.js/):
|
||||
|
||||
nvm install iojs
|
||||
|
||||
If you want to use the system-installed version of node, you can use the special default alias "system":
|
||||
|
||||
nvm use system
|
||||
nvm run system --version
|
||||
|
||||
If you want to see what versions are installed:
|
||||
|
||||
nvm ls
|
||||
|
||||
If you want to see what versions are available to install:
|
||||
|
||||
nvm ls-remote
|
||||
|
||||
To restore your PATH, you can deactivate it.
|
||||
|
||||
nvm deactivate
|
||||
|
||||
To set a default Node version to be used in any new shell, use the alias 'default':
|
||||
|
||||
nvm alias default stable
|
||||
|
||||
To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
|
||||
|
||||
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
|
||||
nvm install 0.10
|
||||
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 0.10
|
||||
|
||||
To use a mirror of the iojs binaries, set `$NVM_IOJS_ORG_MIRROR`:
|
||||
|
||||
export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
|
||||
nvm install iojs-v1.0.3
|
||||
|
||||
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3
|
||||
|
||||
`nvm use` will not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs.
|
||||
|
||||
## License
|
||||
|
||||
nvm is released under the MIT license.
|
||||
|
||||
|
||||
Copyright (C) 2010-2014 Tim Caswell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## Running tests
|
||||
Tests are written in [Urchin]. Install Urchin (and other dependencies) like so:
|
||||
|
||||
npm install
|
||||
|
||||
There are slow tests and fast tests. The slow tests do things like install node
|
||||
and check that the right versions are used. The fast tests fake this to test
|
||||
things like aliases and uninstalling. From the root of the nvm git repository,
|
||||
run the fast tests like this.
|
||||
|
||||
npm run test/fast
|
||||
|
||||
Run the slow tests like this.
|
||||
|
||||
npm run test/slow
|
||||
|
||||
Run all of the tests like this
|
||||
|
||||
npm test
|
||||
|
||||
Nota bene: Avoid running nvm while the tests are running.
|
||||
|
||||
## Bash completion
|
||||
|
||||
To activate, you need to source `bash_completion`:
|
||||
|
||||
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion
|
||||
|
||||
Put the above sourcing line just below the sourcing line for NVM in your profile (`.bashrc`, `.bash_profile`).
|
||||
|
||||
### Usage
|
||||
|
||||
nvm
|
||||
|
||||
$ nvm [tab][tab]
|
||||
alias deactivate install ls run unload
|
||||
clear-cache exec list ls-remote unalias use
|
||||
current help list-remote reinstall-packages uninstall version
|
||||
|
||||
nvm alias
|
||||
|
||||
$ nvm alias [tab][tab]
|
||||
default
|
||||
|
||||
$ nvm alias my_alias [tab][tab]
|
||||
v0.6.21 v0.8.26 v0.10.28
|
||||
|
||||
nvm use
|
||||
|
||||
$ nvm use [tab][tab]
|
||||
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||
|
||||
nvm uninstall
|
||||
|
||||
$ nvm uninstall [tab][tab]
|
||||
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||
|
||||
## Problems
|
||||
|
||||
If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following:
|
||||
|
||||
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
|
||||
|
||||
Where's my 'sudo node'? Check out this link:
|
||||
|
||||
https://github.com/creationix/nvm/issues/43
|
||||
|
||||
On Arch Linux and other systems using python3 by default, before running *install* you need to
|
||||
|
||||
export PYTHON=python2
|
||||
|
||||
After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source:
|
||||
|
||||
nvm install -s 0.8.6
|
||||
|
||||
[1]: https://github.com/creationix/nvm.git
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.24.2/install.sh
|
||||
[3]: https://travis-ci.org/creationix/nvm
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Fish]: http://fishshell.com
|
@@ -1,9 +0,0 @@
|
||||
# nvm Road Map
|
||||
|
||||
This is a list of the primary features planned for `nvm`:
|
||||
|
||||
- [x] Rewriting installation code paths to support installing `io.js` and `node` `v4+` [from source](https://github.com/nvm-sh/nvm/issues/1188).
|
||||
- This will include [reusing previously downloaded tarballs](https://github.com/nvm-sh/nvm/issues/1193) that match checksums, which is a nice performance and bandwidth bonus.
|
||||
- [ ] Adding opt-in environment variable support to list, download, and install `node` [release candidates](https://github.com/nvm-sh/nvm/issues/779), and [nightly builds](https://github.com/nvm-sh/nvm/issues/1053).
|
||||
- [ ] [`nvm update`](https://github.com/nvm-sh/nvm/issues/400): the ability to autoupdate `nvm` itself
|
||||
- [ ] [v1.0.0](https://github.com/nvm-sh/nvm/milestone/1), including updating the [nvm on npm](https://github.com/nvm-sh/nvm/issues/304) to auto-install nvm properly
|
@@ -2,79 +2,80 @@
|
||||
|
||||
# bash completion for Node Version Manager (NVM)
|
||||
|
||||
if ! command -v nvm &> /dev/null; then
|
||||
return
|
||||
fi
|
||||
|
||||
__nvm_generate_completion() {
|
||||
__nvm_generate_completion()
|
||||
{
|
||||
declare current_word
|
||||
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$1" -- "${current_word}"))
|
||||
COMPREPLY=($(compgen -W "$1" -- "$current_word"))
|
||||
return 0
|
||||
}
|
||||
|
||||
__nvm_commands() {
|
||||
__nvm_commands ()
|
||||
{
|
||||
declare current_word
|
||||
declare command
|
||||
|
||||
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
COMMANDS='
|
||||
help install uninstall use run exec
|
||||
alias unalias reinstall-packages
|
||||
current list ls list-remote ls-remote
|
||||
install-latest-npm
|
||||
cache deactivate unload
|
||||
version version-remote which'
|
||||
COMMANDS='\
|
||||
help install uninstall use run exec \
|
||||
alias unalias reinstall-packages \
|
||||
current list ls list-remote ls-remote \
|
||||
clear-cache deactivate unload \
|
||||
version which'
|
||||
|
||||
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||
|
||||
command="${COMP_WORDS[COMP_CWORD - 2]}"
|
||||
case "${command}" in
|
||||
alias) __nvm_installed_nodes ;;
|
||||
esac
|
||||
command="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
case "${command}" in
|
||||
alias) __nvm_installed_nodes ;;
|
||||
esac
|
||||
|
||||
else
|
||||
else
|
||||
|
||||
case "${current_word}" in
|
||||
-*) __nvm_options ;;
|
||||
*) __nvm_generate_completion "${COMMANDS}" ;;
|
||||
esac
|
||||
case "${current_word}" in
|
||||
-*) __nvm_options ;;
|
||||
*) __nvm_generate_completion "$COMMANDS" ;;
|
||||
esac
|
||||
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
__nvm_options() {
|
||||
__nvm_options ()
|
||||
{
|
||||
OPTIONS=''
|
||||
__nvm_generate_completion "${OPTIONS}"
|
||||
__nvm_generate_completion "$OPTIONS"
|
||||
}
|
||||
|
||||
__nvm_installed_nodes() {
|
||||
__nvm_installed_nodes ()
|
||||
{
|
||||
__nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)"
|
||||
}
|
||||
|
||||
__nvm_aliases() {
|
||||
__nvm_aliases ()
|
||||
{
|
||||
declare aliases
|
||||
aliases=""
|
||||
if [ -d "${NVM_DIR}/alias" ]; then
|
||||
aliases="$(command cd "${NVM_DIR}/alias" && command find "${PWD}" -type f | command sed "s:${PWD}/::")"
|
||||
if [ -d $NVM_DIR/alias ]; then
|
||||
aliases="`cd $NVM_DIR/alias && ls`"
|
||||
fi
|
||||
echo "${aliases} node stable unstable iojs"
|
||||
echo "${aliases}"
|
||||
}
|
||||
|
||||
__nvm_alias() {
|
||||
__nvm_alias ()
|
||||
{
|
||||
__nvm_generate_completion "$(__nvm_aliases)"
|
||||
}
|
||||
|
||||
__nvm() {
|
||||
__nvm ()
|
||||
{
|
||||
declare previous_word
|
||||
previous_word="${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
case "${previous_word}" in
|
||||
use | run | exec | ls | list | uninstall) __nvm_installed_nodes ;;
|
||||
alias | unalias) __nvm_alias ;;
|
||||
*) __nvm_commands ;;
|
||||
case "$previous_word" in
|
||||
use|run|exec|ls|list|uninstall) __nvm_installed_nodes ;;
|
||||
alias|unalias) __nvm_alias ;;
|
||||
*) __nvm_commands ;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
@@ -84,16 +85,8 @@ __nvm() {
|
||||
# called bashcompinit that will create a complete in ZSH. If the user is in
|
||||
# ZSH, load and run bashcompinit before calling the complete function.
|
||||
if [[ -n ${ZSH_VERSION-} ]]; then
|
||||
# First calling compinit (only if not called yet!)
|
||||
# and then bashcompinit as mentioned by zsh man page.
|
||||
if ! command -v compinit > /dev/null; then
|
||||
autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
|
||||
compinit -u
|
||||
else
|
||||
compinit
|
||||
fi
|
||||
fi
|
||||
autoload -U +X bashcompinit && bashcompinit
|
||||
autoload -U +X bashcompinit && bashcompinit
|
||||
fi
|
||||
|
||||
complete -o default -F __nvm nvm
|
||||
complete -o default -o nospace -F __nvm nvm
|
||||
|
||||
|
475
install.sh
475
install.sh
@@ -1,274 +1,108 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/bash
|
||||
|
||||
{ # this ensures the entire script is downloaded #
|
||||
set -e
|
||||
|
||||
nvm_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
nvm_echo() {
|
||||
command printf %s\\n "$*" 2>/dev/null
|
||||
}
|
||||
|
||||
if [ -z "${BASH_VERSION}" ] || [ -n "${ZSH_VERSION}" ]; then
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo >&2 'Error: the install instructions explicitly say to pipe the install script to `bash`; please follow them'
|
||||
exit 1
|
||||
if [ -z "$NVM_DIR" ]; then
|
||||
NVM_DIR="$HOME/.nvm"
|
||||
fi
|
||||
|
||||
nvm_grep() {
|
||||
GREP_OPTIONS='' command grep "$@"
|
||||
}
|
||||
|
||||
nvm_default_install_dir() {
|
||||
[ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm"
|
||||
}
|
||||
|
||||
nvm_install_dir() {
|
||||
if [ -n "$NVM_DIR" ]; then
|
||||
printf %s "${NVM_DIR}"
|
||||
else
|
||||
nvm_default_install_dir
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_latest_version() {
|
||||
nvm_echo "v0.40.3"
|
||||
}
|
||||
|
||||
nvm_profile_is_bash_or_zsh() {
|
||||
local TEST_PROFILE
|
||||
TEST_PROFILE="${1-}"
|
||||
case "${TEST_PROFILE-}" in
|
||||
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc" | *"/.zprofile")
|
||||
return
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
echo "v0.24.2"
|
||||
}
|
||||
|
||||
#
|
||||
# Outputs the location to NVM depending on:
|
||||
# * The availability of $NVM_SOURCE
|
||||
# * The presence of $NVM_INSTALL_GITHUB_REPO
|
||||
# * The method used ("script" or "git" in the script, defaults to "git")
|
||||
# NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
|
||||
#
|
||||
nvm_source() {
|
||||
local NVM_GITHUB_REPO
|
||||
NVM_GITHUB_REPO="${NVM_INSTALL_GITHUB_REPO:-nvm-sh/nvm}"
|
||||
if [ "${NVM_GITHUB_REPO}" != 'nvm-sh/nvm' ]; then
|
||||
{ nvm_echo >&2 "$(cat)" ; } << EOF
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@ WARNING: REMOTE REPO IDENTIFICATION HAS CHANGED! @
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
|
||||
|
||||
The default repository for this install is \`nvm-sh/nvm\`,
|
||||
but the environment variables \`\$NVM_INSTALL_GITHUB_REPO\` is
|
||||
currently set to \`${NVM_GITHUB_REPO}\`.
|
||||
|
||||
If this is not intentional, interrupt this installation and
|
||||
verify your environment variables.
|
||||
EOF
|
||||
fi
|
||||
local NVM_VERSION
|
||||
NVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"
|
||||
local NVM_METHOD
|
||||
NVM_METHOD="$1"
|
||||
local NVM_SOURCE_URL
|
||||
NVM_SOURCE_URL="$NVM_SOURCE"
|
||||
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm-exec"
|
||||
elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/bash_completion"
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
|
||||
elif [ -z "$NVM_SOURCE_URL" ]; then
|
||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm.sh"
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
|
||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||
NVM_SOURCE_URL="https://github.com/${NVM_GITHUB_REPO}.git"
|
||||
NVM_SOURCE_URL="https://github.com/creationix/nvm.git"
|
||||
else
|
||||
nvm_echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
nvm_echo "$NVM_SOURCE_URL"
|
||||
}
|
||||
|
||||
#
|
||||
# Node.js version to install
|
||||
#
|
||||
nvm_node_version() {
|
||||
nvm_echo "$NODE_VERSION"
|
||||
echo "$NVM_SOURCE_URL"
|
||||
}
|
||||
|
||||
nvm_download() {
|
||||
if nvm_has "curl"; then
|
||||
curl --fail --compressed -q "$@"
|
||||
curl $*
|
||||
elif nvm_has "wget"; then
|
||||
# Emulate curl with wget
|
||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/--compressed //' \
|
||||
-e 's/--fail //' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
-e 's/-sS /-nv /' \
|
||||
-e 's/-o /-O /' \
|
||||
-e 's/-C - /-c /')
|
||||
# shellcheck disable=SC2086
|
||||
eval wget $ARGS
|
||||
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
-e 's/-o /-O /' \
|
||||
-e 's/-C - /-c /')
|
||||
wget $ARGS
|
||||
fi
|
||||
}
|
||||
|
||||
install_nvm_from_git() {
|
||||
local INSTALL_DIR
|
||||
INSTALL_DIR="$(nvm_install_dir)"
|
||||
local NVM_VERSION
|
||||
NVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"
|
||||
if [ -n "${NVM_INSTALL_VERSION:-}" ]; then
|
||||
# Check if version is an existing ref
|
||||
if command git ls-remote "$(nvm_source "git")" "$NVM_VERSION" | nvm_grep -q "$NVM_VERSION" ; then
|
||||
:
|
||||
# Check if version is an existing changeset
|
||||
elif ! nvm_download -o /dev/null "$(nvm_source "script-nvm-exec")"; then
|
||||
nvm_echo >&2 "Failed to find '$NVM_VERSION' version."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local fetch_error
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
# Updating repo
|
||||
nvm_echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
|
||||
command printf '\r=> '
|
||||
fetch_error="Failed to update nvm with $NVM_VERSION, run 'git fetch' in $INSTALL_DIR yourself."
|
||||
if [ -d "$NVM_DIR/.git" ]; then
|
||||
echo "=> nvm is already installed in $NVM_DIR, trying to update using git"
|
||||
printf "\r=> "
|
||||
cd "$NVM_DIR" && (command git fetch 2> /dev/null || {
|
||||
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
|
||||
})
|
||||
else
|
||||
fetch_error="Failed to fetch origin with $NVM_VERSION. Please report this!"
|
||||
nvm_echo "=> Downloading nvm from git to '$INSTALL_DIR'"
|
||||
command printf '\r=> '
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
if [ "$(ls -A "${INSTALL_DIR}")" ]; then
|
||||
# Initializing repo
|
||||
command git init "${INSTALL_DIR}" || {
|
||||
nvm_echo >&2 'Failed to initialize nvm repo. Please report this!'
|
||||
exit 2
|
||||
}
|
||||
command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
|
||||
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
|
||||
nvm_echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
|
||||
exit 2
|
||||
}
|
||||
else
|
||||
# Cloning repo
|
||||
command git clone "$(nvm_source)" --depth=1 "${INSTALL_DIR}" || {
|
||||
nvm_echo >&2 'Failed to clone nvm repo. Please report this!'
|
||||
exit 2
|
||||
}
|
||||
fi
|
||||
# Cloning to $NVM_DIR
|
||||
echo "=> Downloading nvm from git to '$NVM_DIR'"
|
||||
printf "\r=> "
|
||||
mkdir -p "$NVM_DIR"
|
||||
command git clone "$(nvm_source git)" "$NVM_DIR"
|
||||
fi
|
||||
# Try to fetch tag
|
||||
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$NVM_VERSION" --depth=1 2>/dev/null; then
|
||||
:
|
||||
# Fetch given version
|
||||
elif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin "$NVM_VERSION" --depth=1; then
|
||||
nvm_echo >&2 "$fetch_error"
|
||||
exit 1
|
||||
fi
|
||||
command git -c advice.detachedHead=false --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet FETCH_HEAD || {
|
||||
nvm_echo >&2 "Failed to checkout the given version $NVM_VERSION. Please report this!"
|
||||
exit 2
|
||||
}
|
||||
if [ -n "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
|
||||
if command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
|
||||
command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
|
||||
else
|
||||
nvm_echo >&2 "Your version of git is out of date. Please update it!"
|
||||
command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
nvm_echo "=> Compressing and cleaning up git repository"
|
||||
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" reflog expire --expire=now --all; then
|
||||
nvm_echo >&2 "Your version of git is out of date. Please update it!"
|
||||
fi
|
||||
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --auto --aggressive --prune=now ; then
|
||||
nvm_echo >&2 "Your version of git is out of date. Please update it!"
|
||||
cd "$NVM_DIR" && command git checkout --quiet $(nvm_latest_version)
|
||||
if [ ! -z "$(cd "$NVM_DIR" && git show-ref refs/heads/master)" ]; then
|
||||
cd "$NVM_DIR" && command git branch --quiet -D master >/dev/null 2>&1
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
#
|
||||
# Automatically install Node.js
|
||||
#
|
||||
nvm_install_node() {
|
||||
local NODE_VERSION_LOCAL
|
||||
NODE_VERSION_LOCAL="$(nvm_node_version)"
|
||||
|
||||
if [ -z "$NODE_VERSION_LOCAL" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
nvm_echo "=> Installing Node.js version $NODE_VERSION_LOCAL"
|
||||
nvm install "$NODE_VERSION_LOCAL"
|
||||
local CURRENT_NVM_NODE
|
||||
|
||||
CURRENT_NVM_NODE="$(nvm_version current)"
|
||||
if [ "$(nvm_version "$NODE_VERSION_LOCAL")" == "$CURRENT_NVM_NODE" ]; then
|
||||
nvm_echo "=> Node.js version $NODE_VERSION_LOCAL has been successfully installed"
|
||||
else
|
||||
nvm_echo >&2 "Failed to install Node.js $NODE_VERSION_LOCAL"
|
||||
fi
|
||||
}
|
||||
|
||||
install_nvm_as_script() {
|
||||
local INSTALL_DIR
|
||||
INSTALL_DIR="$(nvm_install_dir)"
|
||||
local NVM_SOURCE_LOCAL
|
||||
NVM_SOURCE_LOCAL="$(nvm_source script)"
|
||||
NVM_SOURCE_LOCAL=$(nvm_source script)
|
||||
local NVM_EXEC_SOURCE
|
||||
NVM_EXEC_SOURCE="$(nvm_source script-nvm-exec)"
|
||||
local NVM_BASH_COMPLETION_SOURCE
|
||||
NVM_BASH_COMPLETION_SOURCE="$(nvm_source script-nvm-bash-completion)"
|
||||
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
|
||||
|
||||
# Downloading to $INSTALL_DIR
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
if [ -f "$INSTALL_DIR/nvm.sh" ]; then
|
||||
nvm_echo "=> nvm is already installed in $INSTALL_DIR, trying to update the script"
|
||||
# Downloading to $NVM_DIR
|
||||
mkdir -p "$NVM_DIR"
|
||||
if [ -d "$NVM_DIR/nvm.sh" ]; then
|
||||
echo "=> nvm is already installed in $NVM_DIR, trying to update the script"
|
||||
else
|
||||
nvm_echo "=> Downloading nvm as script to '$INSTALL_DIR'"
|
||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||
fi
|
||||
nvm_download -s "$NVM_SOURCE_LOCAL" -o "$INSTALL_DIR/nvm.sh" || {
|
||||
nvm_echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
|
||||
nvm_download -s "$NVM_SOURCE_LOCAL" -o "$NVM_DIR/nvm.sh" || {
|
||||
echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
|
||||
return 1
|
||||
} &
|
||||
nvm_download -s "$NVM_EXEC_SOURCE" -o "$INSTALL_DIR/nvm-exec" || {
|
||||
nvm_echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
|
||||
}
|
||||
nvm_download -s "$NVM_EXEC_SOURCE" -o "$NVM_DIR/nvm-exec" || {
|
||||
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
|
||||
return 2
|
||||
} &
|
||||
nvm_download -s "$NVM_BASH_COMPLETION_SOURCE" -o "$INSTALL_DIR/bash_completion" || {
|
||||
nvm_echo >&2 "Failed to download '$NVM_BASH_COMPLETION_SOURCE'"
|
||||
return 2
|
||||
} &
|
||||
for job in $(jobs -p | command sort)
|
||||
do
|
||||
wait "$job" || return $?
|
||||
done
|
||||
chmod a+x "$INSTALL_DIR/nvm-exec" || {
|
||||
nvm_echo >&2 "Failed to mark '$INSTALL_DIR/nvm-exec' as executable"
|
||||
}
|
||||
chmod a+x "$NVM_DIR/nvm-exec" || {
|
||||
echo >&2 "Failed to mark '$NVM_DIR/nvm-exec' as executable"
|
||||
return 3
|
||||
}
|
||||
}
|
||||
|
||||
nvm_try_profile() {
|
||||
if [ -z "${1-}" ] || [ ! -f "${1}" ]; then
|
||||
return 1
|
||||
fi
|
||||
nvm_echo "${1}"
|
||||
}
|
||||
|
||||
#
|
||||
# Detect profile file if not specified as environment variable
|
||||
# (eg: PROFILE=~/.myprofile)
|
||||
@@ -276,44 +110,16 @@ nvm_try_profile() {
|
||||
# Otherwise, an empty string is returned
|
||||
#
|
||||
nvm_detect_profile() {
|
||||
if [ "${PROFILE-}" = '/dev/null' ]; then
|
||||
# the user has specifically requested NOT to have nvm touch their profile
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then
|
||||
nvm_echo "${PROFILE}"
|
||||
return
|
||||
fi
|
||||
|
||||
local DETECTED_PROFILE
|
||||
DETECTED_PROFILE=''
|
||||
|
||||
if [ "${SHELL#*bash}" != "$SHELL" ]; then
|
||||
if [ -f "$HOME/.bashrc" ]; then
|
||||
DETECTED_PROFILE="$HOME/.bashrc"
|
||||
elif [ -f "$HOME/.bash_profile" ]; then
|
||||
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||
fi
|
||||
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
|
||||
if [ -f "${ZDOTDIR:-${HOME}}/.zshrc" ]; then
|
||||
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zshrc"
|
||||
elif [ -f "${ZDOTDIR:-${HOME}}/.zprofile" ]; then
|
||||
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zprofile"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$DETECTED_PROFILE" ]; then
|
||||
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc"
|
||||
do
|
||||
if DETECTED_PROFILE="$(nvm_try_profile "${ZDOTDIR:-${HOME}}/${EACH_PROFILE}")"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$DETECTED_PROFILE" ]; then
|
||||
nvm_echo "$DETECTED_PROFILE"
|
||||
if [ -f "$PROFILE" ]; then
|
||||
echo "$PROFILE"
|
||||
elif [ -f "$HOME/.bashrc" ]; then
|
||||
echo "$HOME/.bashrc"
|
||||
elif [ -f "$HOME/.bash_profile" ]; then
|
||||
echo "$HOME/.bash_profile"
|
||||
elif [ -f "$HOME/.zshrc" ]; then
|
||||
echo "$HOME/.zshrc"
|
||||
elif [ -f "$HOME/.profile" ]; then
|
||||
echo "$HOME/.profile"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -322,9 +128,7 @@ nvm_detect_profile() {
|
||||
# Node, and warn them if so.
|
||||
#
|
||||
nvm_check_global_modules() {
|
||||
local NPM_COMMAND
|
||||
NPM_COMMAND="$(command -v npm 2>/dev/null)" || return 0
|
||||
[ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%"$NVM_DIR"/*}" ] && return 0
|
||||
command -v npm >/dev/null 2>&1 || return 0
|
||||
|
||||
local NPM_VERSION
|
||||
NPM_VERSION="$(npm --version)"
|
||||
@@ -334,149 +138,91 @@ nvm_check_global_modules() {
|
||||
local NPM_GLOBAL_MODULES
|
||||
NPM_GLOBAL_MODULES="$(
|
||||
npm list -g --depth=0 |
|
||||
command sed -e '/ npm@/d' -e '/ (empty)$/d'
|
||||
sed '/ npm@/d' |
|
||||
sed '/ (empty)$/d'
|
||||
)"
|
||||
|
||||
local MODULE_COUNT
|
||||
MODULE_COUNT="$(
|
||||
command printf %s\\n "$NPM_GLOBAL_MODULES" |
|
||||
command sed -ne '1!p' | # Remove the first line
|
||||
wc -l | command tr -d ' ' # Count entries
|
||||
printf %s\\n "$NPM_GLOBAL_MODULES" |
|
||||
sed -ne '1!p' | # Remove the first line
|
||||
wc -l | tr -d ' ' # Count entries
|
||||
)"
|
||||
|
||||
if [ "${MODULE_COUNT}" != '0' ]; then
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo '=> You currently have modules installed globally with `npm`. These will no'
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo '=> longer be linked to the active version of Node when you install a new node'
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo '=> with `nvm`; and they may (depending on how you construct your `$PATH`)'
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo '=> override the binaries of modules installed with `nvm`:'
|
||||
nvm_echo
|
||||
if [ $MODULE_COUNT -ne 0 ]; then
|
||||
cat <<-'END_MESSAGE'
|
||||
=> You currently have modules installed globally with `npm`. These will no
|
||||
=> longer be linked to the active version of Node when you install a new node
|
||||
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
|
||||
=> override the binaries of modules installed with `nvm`:
|
||||
|
||||
command printf %s\\n "$NPM_GLOBAL_MODULES"
|
||||
nvm_echo '=> If you wish to uninstall them at a later point (or re-install them under your'
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo '=> `nvm` node installs), you can remove them from the system Node as follows:'
|
||||
nvm_echo
|
||||
nvm_echo ' $ nvm use system'
|
||||
nvm_echo ' $ npm uninstall -g a_module'
|
||||
nvm_echo
|
||||
END_MESSAGE
|
||||
printf %s\\n "$NPM_GLOBAL_MODULES"
|
||||
cat <<-'END_MESSAGE'
|
||||
|
||||
=> If you wish to uninstall them at a later point (or re-install them under your
|
||||
=> `nvm` Nodes), you can remove them from the system Node as follows:
|
||||
|
||||
$ nvm use system
|
||||
$ npm uninstall -g a_module
|
||||
|
||||
END_MESSAGE
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_do_install() {
|
||||
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
|
||||
if [ -e "${NVM_DIR}" ]; then
|
||||
nvm_echo >&2 "File \"${NVM_DIR}\" has the same name as installation directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${NVM_DIR}" = "$(nvm_default_install_dir)" ]; then
|
||||
mkdir "${NVM_DIR}"
|
||||
else
|
||||
nvm_echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# Disable the optional which check, https://www.shellcheck.net/wiki/SC2230
|
||||
# shellcheck disable=SC2230
|
||||
if nvm_has xcode-select && [ "$(xcode-select -p >/dev/null 2>/dev/null ; echo $?)" = '2' ] && [ "$(which git)" = '/usr/bin/git' ] && [ "$(which curl)" = '/usr/bin/curl' ]; then
|
||||
nvm_echo >&2 'You may be on a Mac, and need to install the Xcode Command Line Developer Tools.'
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo >&2 'If so, run `xcode-select --install` and try again. If not, please report this!'
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${METHOD}" ]; then
|
||||
if [ -z "$METHOD" ]; then
|
||||
# Autodetect install method
|
||||
if nvm_has git; then
|
||||
if nvm_has "git"; then
|
||||
install_nvm_from_git
|
||||
elif nvm_has curl || nvm_has wget; then
|
||||
elif nvm_has "nvm_download"; then
|
||||
install_nvm_as_script
|
||||
else
|
||||
nvm_echo >&2 'You need git, curl, or wget to install nvm'
|
||||
echo >&2 "You need git, curl, or wget to install nvm"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "${METHOD}" = 'git' ]; then
|
||||
if ! nvm_has git; then
|
||||
nvm_echo >&2 "You need git to install nvm"
|
||||
elif [ "~$METHOD" = "~git" ]; then
|
||||
if ! nvm_has "git"; then
|
||||
echo >&2 "You need git to install nvm"
|
||||
exit 1
|
||||
fi
|
||||
install_nvm_from_git
|
||||
elif [ "${METHOD}" = 'script' ]; then
|
||||
if ! nvm_has curl && ! nvm_has wget; then
|
||||
nvm_echo >&2 "You need curl or wget to install nvm"
|
||||
elif [ "~$METHOD" = "~script" ]; then
|
||||
if ! nvm_has "nvm_download"; then
|
||||
echo >&2 "You need curl or wget to install nvm"
|
||||
exit 1
|
||||
fi
|
||||
install_nvm_as_script
|
||||
else
|
||||
nvm_echo >&2 "The environment variable \$METHOD is set to \"${METHOD}\", which is not recognized as a valid installation method."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nvm_echo
|
||||
echo
|
||||
|
||||
local NVM_PROFILE
|
||||
NVM_PROFILE="$(nvm_detect_profile)"
|
||||
local PROFILE_INSTALL_DIR
|
||||
PROFILE_INSTALL_DIR="$(nvm_install_dir | command sed "s:^$HOME:\$HOME:")"
|
||||
NVM_PROFILE=$(nvm_detect_profile)
|
||||
|
||||
SOURCE_STR="\\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\\n"
|
||||
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
COMPLETION_STR='[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion\n'
|
||||
BASH_OR_ZSH=false
|
||||
|
||||
if [ -z "${NVM_PROFILE-}" ] ; then
|
||||
local TRIED_PROFILE
|
||||
if [ -n "${PROFILE}" ]; then
|
||||
TRIED_PROFILE="${NVM_PROFILE} (as defined in \$PROFILE), "
|
||||
fi
|
||||
nvm_echo "=> Profile not found. Tried ${TRIED_PROFILE-}~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile."
|
||||
nvm_echo "=> Create one of them and run this script again"
|
||||
nvm_echo " OR"
|
||||
nvm_echo "=> Append the following lines to the correct file yourself:"
|
||||
command printf "${SOURCE_STR}"
|
||||
nvm_echo
|
||||
if [ -z "$NVM_PROFILE" ] ; then
|
||||
echo "=> Profile not found. Tried $NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
||||
echo "=> Create one of them and run this script again"
|
||||
echo "=> Create it (touch $NVM_PROFILE) and run this script again"
|
||||
echo " OR"
|
||||
echo "=> Append the following lines to the correct file yourself:"
|
||||
printf "$SOURCE_STR"
|
||||
echo
|
||||
else
|
||||
if nvm_profile_is_bash_or_zsh "${NVM_PROFILE-}"; then
|
||||
BASH_OR_ZSH=true
|
||||
fi
|
||||
if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
|
||||
nvm_echo "=> Appending nvm source string to $NVM_PROFILE"
|
||||
command printf "${SOURCE_STR}" >> "$NVM_PROFILE"
|
||||
if ! grep -qc 'nvm.sh' "$NVM_PROFILE"; then
|
||||
echo "=> Appending source string to $NVM_PROFILE"
|
||||
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
|
||||
else
|
||||
nvm_echo "=> nvm source string already in ${NVM_PROFILE}"
|
||||
fi
|
||||
# shellcheck disable=SC2016
|
||||
if ${BASH_OR_ZSH} && ! command grep -qc '$NVM_DIR/bash_completion' "$NVM_PROFILE"; then
|
||||
nvm_echo "=> Appending bash_completion source string to $NVM_PROFILE"
|
||||
command printf "$COMPLETION_STR" >> "$NVM_PROFILE"
|
||||
else
|
||||
nvm_echo "=> bash_completion source string already in ${NVM_PROFILE}"
|
||||
echo "=> Source string already in $NVM_PROFILE"
|
||||
fi
|
||||
fi
|
||||
if ${BASH_OR_ZSH} && [ -z "${NVM_PROFILE-}" ] ; then
|
||||
nvm_echo "=> Please also append the following lines to the if you are using bash/zsh shell:"
|
||||
command printf "${COMPLETION_STR}"
|
||||
fi
|
||||
|
||||
# Source nvm
|
||||
# shellcheck source=/dev/null
|
||||
\. "$(nvm_install_dir)/nvm.sh"
|
||||
|
||||
nvm_check_global_modules
|
||||
|
||||
nvm_install_node
|
||||
|
||||
echo "=> Close and reopen your terminal to start using nvm"
|
||||
nvm_reset
|
||||
|
||||
nvm_echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
|
||||
command printf "${SOURCE_STR}"
|
||||
if ${BASH_OR_ZSH} ; then
|
||||
command printf "${COMPLETION_STR}"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
@@ -484,12 +230,9 @@ nvm_do_install() {
|
||||
# during the execution of the install script
|
||||
#
|
||||
nvm_reset() {
|
||||
unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \
|
||||
nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \
|
||||
install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \
|
||||
nvm_do_install nvm_reset nvm_default_install_dir nvm_grep
|
||||
unset -f nvm_reset nvm_has nvm_latest_version \
|
||||
nvm_source nvm_download install_nvm_as_script install_nvm_from_git \
|
||||
nvm_detect_profile nvm_check_global_modules nvm_do_install
|
||||
}
|
||||
|
||||
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
||||
|
||||
} # this ensures the entire script is downloaded #
|
||||
|
17
nvm-exec
17
nvm-exec
@@ -1,17 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
unset NVM_CD_FLAGS
|
||||
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
\. "$DIR/nvm.sh" --no-use
|
||||
source "$DIR/nvm.sh"
|
||||
|
||||
if [ -n "$NODE_VERSION" ]; then
|
||||
nvm use "$NODE_VERSION" > /dev/null || exit 127
|
||||
elif ! nvm use >/dev/null 2>&1; then
|
||||
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
|
||||
exit 127
|
||||
nvm use $NODE_VERSION > /dev/null || (echo "NODE_VERSION not set" >&2 && exit 127)
|
||||
else
|
||||
nvm use > /dev/null || (echo "No .nvmrc file found" >&2 && exit 127)
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
exec $@
|
||||
|
||||
|
36
package.json
36
package.json
@@ -1,53 +1,37 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.40.3",
|
||||
"version": "0.24.2",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make test-$shell",
|
||||
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); env -i TERM=\"$TERM\" bash -lc \"make TEST_SUITE=fast test-$shell\"",
|
||||
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=fast test-$shell",
|
||||
"test/slow": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=slow test-$shell",
|
||||
"test/install_script": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=install_script test-$shell",
|
||||
"test/installation": "npm run --silent test/installation/node && npm run --silent test/installation/iojs",
|
||||
"test/installation/node": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation_node test-$shell",
|
||||
"test/installation/iojs": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation_iojs test-$shell",
|
||||
"test/sourcing": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=sourcing test-$shell",
|
||||
"test:check-exec": "(IFS=$'\\n'; for file in $(git ls-files test); do if [ ! -x \"$file\" ] && [[ \"$file\" != *.* ]] && [[ \"$file\" != test/fixtures/* ]]; then echo \"$file\"; fi; done) | tee /dev/stderr | awk 'END {if (NR > 0) exit 1}'",
|
||||
"test:check-nonexec": "(IFS=$'\\n'; for file in $(git ls-files test); do if [ -x \"$file\" ] && [ ! -d \"$file\" ] && { [[ \"$file\" =~ '\\.(json|txt|sh|js|log)$' ]] || [[ \"$file\" =~ '^test/(mocks|fixtures)/.*' ]]; }; then echo \"$file\"; fi; done) | tee /dev/stderr | awk 'END {if (NR > 0) exit 1}'",
|
||||
"doctoc": "doctoc --title='## Table of Contents' --github README.md",
|
||||
"predoctoc:check": "cp README.md v-README.md.orig && npm run doctoc",
|
||||
"doctoc:check": "diff -q README.md v-README.md.orig",
|
||||
"postdoctoc:check": "mv v-README.md.orig README.md",
|
||||
"eclint": "eclint check $(git ls-tree --name-only HEAD | xargs)",
|
||||
"dockerfile_lint": "dockerfile_lint",
|
||||
"markdown-link-check": "git ls-files | command grep -E '\\.md$' | xargs -n 1 markdown-link-check -p"
|
||||
"test/installation": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation test-$shell",
|
||||
"test/sourcing": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=sourcing test-$shell"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nvm-sh/nvm.git"
|
||||
"url": "git://github.com/creationix/nvm.git"
|
||||
},
|
||||
"keywords": [
|
||||
"nvm",
|
||||
"node",
|
||||
"iojs",
|
||||
"version",
|
||||
"manager"
|
||||
],
|
||||
"author": "Tim Caswell <tim@creationix.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nvm-sh/nvm/issues"
|
||||
"url": "https://github.com/creationix/nvm/issues"
|
||||
},
|
||||
"homepage": "https://github.com/nvm-sh/nvm",
|
||||
"homepage": "https://github.com/creationix/nvm",
|
||||
"devDependencies": {
|
||||
"dockerfile_lint": "^0.3.4",
|
||||
"doctoc": "^2.2.1",
|
||||
"eclint": "^2.8.1",
|
||||
"markdown-link-check": "^3.13.7",
|
||||
"replace": "^1.2.2",
|
||||
"semver": "^7.7.1",
|
||||
"urchin": "^0.0.5"
|
||||
"replace": "~0.3.0",
|
||||
"semver": "~4.2.0",
|
||||
"urchin": "~0.0.5"
|
||||
}
|
||||
}
|
||||
|
@@ -1,52 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
find_name(){
|
||||
find test -name "*[\\/:\*\?\"<>\|]*" -o -name "*."
|
||||
}
|
||||
|
||||
check_name() {
|
||||
if [ "$(find_name | wc -l)" != "0" ]; then
|
||||
printf '%s\n\n' "The following filenames contain unwanted characters:"
|
||||
find_name
|
||||
printf '\n%s\n%s\n' "Please run ./rename_test.sh" "If the problem persist, please open an issue."
|
||||
exit 1
|
||||
else
|
||||
echo "Ok"
|
||||
fi
|
||||
}
|
||||
|
||||
rename_test() {
|
||||
local filename
|
||||
local new_filename
|
||||
while read -r filename; do
|
||||
# Even though it looks < and > are replaced by the same < and >, the latters are not ASCII code
|
||||
# If you check with 'cat -v rename_test.sh' you would see 's/</M-KM-^B/g' and 's/>/M-KM-^C/g'
|
||||
# M-KM-^B -> U+02C2
|
||||
# M-KM-^C -> U+02C3
|
||||
new_filename=$(echo "$filename" | sed -r \
|
||||
-e "s/\"/'/g" \
|
||||
-e 's/</˂/g' \
|
||||
-e 's/>/˃/g' \
|
||||
-e 's/^(.*)\.$/\1/'
|
||||
)
|
||||
printf '%s\n%s\n\n' "$filename" "$new_filename"
|
||||
[ "$filename" != "$new_filename" ] && git mv "$filename" "$new_filename"
|
||||
done < <(find_name)
|
||||
|
||||
if [ "$(find_name | wc -l)" != "0" ]; then
|
||||
echo "Still some files to treat:"
|
||||
find_name
|
||||
else
|
||||
echo "Done"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ "$1" = "--check" ]; then
|
||||
check_name
|
||||
else
|
||||
rename_test
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
247
test/common.sh
247
test/common.sh
@@ -1,247 +0,0 @@
|
||||
assert_ok() {
|
||||
local FUNCTION=$1
|
||||
shift
|
||||
|
||||
$($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have succeeded, but failed'
|
||||
}
|
||||
|
||||
assert_not_ok() {
|
||||
local FUNCTION=$1
|
||||
shift
|
||||
|
||||
! $($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have failed, but succeeded'
|
||||
}
|
||||
|
||||
strip_colors() {
|
||||
while read -r line; do
|
||||
echo "$line" | LC_ALL=C command sed 's/\[[ -?]*[@-~]//g'
|
||||
done
|
||||
}
|
||||
|
||||
make_echo() {
|
||||
echo "#!/bin/sh" > "$1"
|
||||
echo "echo \"${2}\"" > "$1"
|
||||
chmod a+x "$1"
|
||||
}
|
||||
|
||||
make_fake_node() {
|
||||
local VERSION
|
||||
VERSION="${1-}"
|
||||
[ -n "${VERSION}" ] || return 1
|
||||
|
||||
local FORMATTED_VERSION
|
||||
FORMATTED_VERSION="$(nvm_format_version "${VERSION}")"
|
||||
|
||||
local BIN_PATH
|
||||
BIN_PATH="$(nvm_version_path "${FORMATTED_VERSION}")/bin"
|
||||
[ "${BIN_PATH}" != "/bin" ] || {
|
||||
echo >&2 'nvm_version_path was empty'
|
||||
return 5
|
||||
}
|
||||
|
||||
mkdir -p "${BIN_PATH}" || {
|
||||
echo >&2 'unable to make bin dir'
|
||||
return 2
|
||||
}
|
||||
|
||||
make_echo "${BIN_PATH}/node" "${VERSION}" || {
|
||||
echo >&2 'unable to make fake node bin'
|
||||
return 3
|
||||
}
|
||||
|
||||
nvm_is_version_installed "${FORMATTED_VERSION}" || {
|
||||
echo >&2 'fake node is not installed'
|
||||
return 4
|
||||
}
|
||||
}
|
||||
|
||||
make_fake_iojs() {
|
||||
local VERSION
|
||||
VERSION="${1-}"
|
||||
[ -n "${VERSION}" ] || return 1
|
||||
|
||||
local FORMATTED_VERSION
|
||||
FORMATTED_VERSION="$(nvm_format_version "iojs-${VERSION}")"
|
||||
|
||||
local BIN_PATH
|
||||
BIN_PATH="$(nvm_version_path "${FORMATTED_VERSION}")/bin"
|
||||
[ "${BIN_PATH}" != "/bin" ] || {
|
||||
echo >&2 'nvm_version_path was empty'
|
||||
return 5
|
||||
}
|
||||
|
||||
mkdir -p "${BIN_PATH}" || {
|
||||
echo >&2 'unable to make bin dir'
|
||||
return 2
|
||||
}
|
||||
|
||||
make_echo "${BIN_PATH}/node" "${VERSION}" || {
|
||||
echo >&2 'unable to make fake node bin'
|
||||
return 3
|
||||
}
|
||||
make_echo "${BIN_PATH}/iojs" "${VERSION}" || {
|
||||
echo >&2 'unable to make fake iojs bin'
|
||||
return 3
|
||||
}
|
||||
|
||||
nvm_is_version_installed "${FORMATTED_VERSION}" || {
|
||||
echo >&2 'fake iojs is not installed'
|
||||
return 4
|
||||
}
|
||||
}
|
||||
|
||||
watch() {
|
||||
$@ &
|
||||
local JOB
|
||||
JOB=$!
|
||||
while true; do sleep 15; >&2 echo '* ping *'; done &
|
||||
wait $JOB;
|
||||
local EXIT_CODE
|
||||
EXIT_CODE=$?
|
||||
kill %2;
|
||||
return $EXIT_CODE
|
||||
}
|
||||
|
||||
|
||||
# JSON parsing from https://gist.github.com/assaf/ee377a186371e2e269a7
|
||||
nvm_json_throw() {
|
||||
nvm_err "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
nvm_json_awk_egrep() {
|
||||
local pattern_string
|
||||
pattern_string="${1}"
|
||||
|
||||
awk '{
|
||||
while ($0) {
|
||||
start=match($0, pattern);
|
||||
token=substr($0, start, RLENGTH);
|
||||
print token;
|
||||
$0=substr($0, start+RLENGTH);
|
||||
}
|
||||
}' "pattern=${pattern_string}"
|
||||
}
|
||||
|
||||
nvm_json_tokenize() {
|
||||
local GREP
|
||||
GREP='grep -Eao'
|
||||
|
||||
local ESCAPE
|
||||
local CHAR
|
||||
|
||||
# if echo "test string" | grep -Eo "test" > /dev/null 2>&1; then
|
||||
# ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
|
||||
# CHAR='[^[:cntrl:]"\\]'
|
||||
# else
|
||||
GREP=nvm_json_awk_egrep
|
||||
ESCAPE='(\\\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
|
||||
CHAR='[^[:cntrl:]"\\\\]'
|
||||
# fi
|
||||
|
||||
local STRING
|
||||
STRING="\"${CHAR}*(${ESCAPE}${CHAR}*)*\""
|
||||
local NUMBER
|
||||
NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?'
|
||||
local KEYWORD
|
||||
KEYWORD='null|false|true'
|
||||
local SPACE
|
||||
SPACE='[[:space:]]+'
|
||||
|
||||
$GREP "${STRING}|${NUMBER}|${KEYWORD}|${SPACE}|." | TERM=dumb grep -Ev "^${SPACE}$"
|
||||
}
|
||||
|
||||
_json_parse_array() {
|
||||
local index=0
|
||||
local ary=''
|
||||
read -r token
|
||||
case "$token" in
|
||||
']') ;;
|
||||
*)
|
||||
while :; do
|
||||
_json_parse_value "${1}" "${index}"
|
||||
index=$((index+1))
|
||||
ary="${ary}${value}"
|
||||
read -r token
|
||||
case "${token}" in
|
||||
']') break ;;
|
||||
',') ary="${ary}," ;;
|
||||
*) nvm_json_throw "EXPECTED , or ] GOT ${token:-EOF}" ;;
|
||||
esac
|
||||
read -r token
|
||||
done
|
||||
;;
|
||||
esac
|
||||
:
|
||||
}
|
||||
|
||||
_json_parse_object() {
|
||||
local key
|
||||
local obj=''
|
||||
read -r token
|
||||
case "$token" in
|
||||
'}') ;;
|
||||
*)
|
||||
while :; do
|
||||
case "${token}" in
|
||||
'"'*'"') key="${token}" ;;
|
||||
*) nvm_json_throw "EXPECTED string GOT ${token:-EOF}" ;;
|
||||
esac
|
||||
read -r token
|
||||
case "${token}" in
|
||||
':') ;;
|
||||
*) nvm_json_throw "EXPECTED : GOT ${token:-EOF}" ;;
|
||||
esac
|
||||
read -r token
|
||||
_json_parse_value "${1}" "${key}"
|
||||
obj="${obj}${key}:${value}"
|
||||
read -r token
|
||||
case "${token}" in
|
||||
'}') break ;;
|
||||
',') obj="${obj}," ;;
|
||||
*) nvm_json_throw "EXPECTED , or } GOT ${token:-EOF}" ;;
|
||||
esac
|
||||
read -r token
|
||||
done
|
||||
;;
|
||||
esac
|
||||
:
|
||||
}
|
||||
|
||||
_json_parse_value() {
|
||||
local jpath="${1:+$1,}$2"
|
||||
local isleaf=0
|
||||
local isempty=0
|
||||
local print=0
|
||||
|
||||
case "$token" in
|
||||
'{') _json_parse_object "${jpath}" ;;
|
||||
'[') _json_parse_array "${jpath}" ;;
|
||||
# At this point, the only valid single-character tokens are digits.
|
||||
''|[!0-9]) nvm_json_throw "EXPECTED value GOT >${token:-EOF}<" ;;
|
||||
*)
|
||||
value=$token
|
||||
isleaf=1
|
||||
[ "${value}" = '""' ] && isempty=1
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "${value}" = '' ] && return
|
||||
[ "${isleaf}" -eq 1 ] && [ $isempty -eq 0 ] && print=1
|
||||
[ "${print}" -eq 1 ] && printf "[%s]\t%s\n" "${jpath}" "${value}"
|
||||
:
|
||||
}
|
||||
|
||||
_json_parse() {
|
||||
read -r token
|
||||
_json_parse_value
|
||||
read -r token
|
||||
case "${token}" in
|
||||
'') ;;
|
||||
*) nvm_json_throw "EXPECTED EOF GOT >${token}<" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
nvm_json_extract() {
|
||||
nvm_json_tokenize | _json_parse | grep -e "${1}" | awk '{print $2 $3}'
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
die() { echo "$@" ; exit 1; }
|
||||
|
||||
export NVM_DIR="$(cd ../../.. && pwd)"
|
||||
|
||||
\. "${NVM_DIR}/nvm.sh"
|
||||
\. ../../common.sh
|
||||
|
||||
echo "
|
||||
|
||||
v0.0.1
|
||||
" > ../../../alias/test-blank-lines
|
||||
|
||||
EXPECTED='v0.0.1'
|
||||
ACTUAL="$(nvm_alias test-blank-lines)"
|
||||
EXIT_CODE="$(nvm_alias test-blank-lines 2>&1 >/dev/null; echo $?)"
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}"
|
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
OUTPUT="$(nvm alias foo#bar baz 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases with a comment delimiter (#) are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias with a hash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm alias foo#bar baz >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias with a hash should fail with code 1, got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(nvm alias foo# baz 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases with a comment delimiter (#) are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias ending with a hash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm alias foo# baz >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias ending with a hash should fail with code 1, got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(nvm alias \#bar baz 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases with a comment delimiter (#) are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias starting with a hash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm alias \#bar baz >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias starting with a hash should fail with code 1, got '$EXIT_CODE'"
|
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
OUTPUT="$(nvm alias foo/bar baz 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias with a slash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm alias foo/bar baz >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias with a slash should fail with code 1, got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(nvm alias foo/ baz 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias ending with a slash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm alias foo/ baz >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias ending with a slash should fail with code 1, got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(nvm alias /bar baz 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias starting with a slash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm alias /bar baz >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias starting with a slash should fail with code 1, got '$EXIT_CODE'"
|
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
OUTPUT="$(nvm unalias node 2>&1)"
|
||||
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
nvm alias node stable || die '`nvm alias node stable` failed'
|
||||
|
||||
nvm unalias node || die '`nvm unalias node` failed'
|
||||
|
||||
OUTPUT="$(nvm unalias node 2>&1)"
|
||||
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
@@ -1,25 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
OUTPUT="$(nvm unalias node 2>&1)"
|
||||
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias stable 2>&1)"
|
||||
EXPECTED_OUTPUT="stable is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias unstable 2>&1)"
|
||||
EXPECTED_OUTPUT="unstable is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias iojs 2>&1)"
|
||||
EXPECTED_OUTPUT="iojs is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias system 2>&1)"
|
||||
EXPECTED_OUTPUT="system is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
OUTPUT="$(nvm unalias foo/bar 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove an alias with a slash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm unalias foo/bar >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to remove an alias with a slash should fail with code 1, got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(nvm unalias foo/ 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove an alias ending with a slash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm unalias foo/ >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to remove an alias ending with a slash should fail with code 1, got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(nvm unalias /bar 2>&1)"
|
||||
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove an alias starting with a slash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm unalias /bar >/dev/null 2>&1 ; echo $?)"
|
||||
[ "$EXIT_CODE" = "1" ] || die "trying to remove an alias starting with a slash should fail with code 1, got '$EXIT_CODE'"
|
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
# set clobber option in order to test that this does not produce any
|
||||
# incompatibilities
|
||||
setopt noclobber
|
||||
fi
|
||||
|
||||
nvm alias test-stable-1 0.0.2
|
||||
|
||||
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.2 (-> v0.0.2)" \
|
||||
|| die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2"
|
||||
|
||||
nvm alias test-stable-1 0.0.1
|
||||
|
||||
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.1 (-> v0.0.1)" \
|
||||
|| die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1"
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
[ $(nvm alias test-stable-1 | wc -l) = '2' ]
|
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local stable node version"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^node -> stable (-> $STABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local stable node version under 'node'"
|
||||
|
||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local unstable node version"
|
||||
|
||||
EXPECTED_IOJS="$(nvm_print_implicit_alias local iojs)"
|
||||
IOJS_VERSION="$(nvm_version "$EXPECTED_IOJS")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^iojs -> $EXPECTED_IOJS (-> $IOJS_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local iojs version"
|
||||
|
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
cleanup () {
|
||||
rm -rf ../../../alias/stable
|
||||
rm -rf ../../../alias/unstable
|
||||
rm -rf ../../../alias/node
|
||||
rm -rf ../../../alias/iojs
|
||||
rm -rf ../../../v0.8.1
|
||||
rm -rf ../../../v0.9.1
|
||||
rm -rf ../../../versions/io.js/v0.2.1
|
||||
}
|
||||
|
||||
mkdir ../../../v0.8.1
|
||||
mkdir ../../../v0.9.1
|
||||
mkdir -p ../../../versions/io.js/v0.2.1
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
|
||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
|
||||
[ "_$STABLE_VERSION" != "_$UNSTABLE_VERSION" ] \
|
||||
|| die "stable and unstable versions are the same!"
|
||||
|
||||
nvm alias stable "$EXPECTED_UNSTABLE"
|
||||
nvm alias unstable "$EXPECTED_STABLE"
|
||||
nvm alias node stable
|
||||
nvm alias iojs unstable
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'stable' alias"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'unstable' alias"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^node -> stable (-> $UNSTABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'node' alias"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^iojs -> unstable (-> $STABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'iojs' alias"
|
||||
|
||||
cleanup
|
||||
|
48
test/fast/Aliases/Running "nvm alias" should list all aliases.
Executable file
48
test/fast/Aliases/Running "nvm alias" should list all aliases.
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-1 -> 0.0.1 (-> v0.0.1)$' \
|
||||
|| die "did not find test-stable-1 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-2 -> 0.0.2 (-> v0.0.2)$' \
|
||||
|| die "did not find test-stable-2 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-3 -> 0.0.3 (-> v0.0.3)$' \
|
||||
|| die "did not find test-stable-3 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-4 -> 0.0.4 (-> v0.0.4)$' \
|
||||
|| die "did not find test-stable-4 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-5 -> 0.0.5 (-> v0.0.5)$' \
|
||||
|| die "did not find test-stable-5 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-6 -> 0.0.6 (-> v0.0.6)$' \
|
||||
|| die "did not find test-stable-6 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-7 -> 0.0.7 (-> v0.0.7)$' \
|
||||
|| die "did not find test-stable-7 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-8 -> 0.0.8 (-> v0.0.8)$' \
|
||||
|| die "did not find test-stable-8 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-9 -> 0.0.9 (-> v0.0.9)$' \
|
||||
|| die "did not find test-stable-9 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-10 -> 0.0.10 (-> v0.0.10)$' \
|
||||
|| die "did not find test-stable-10 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-1 -> 0.1.1 (-> v0.1.1)$' \
|
||||
|| die "did not find test-unstable-1 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-2 -> 0.1.2 (-> v0.1.2)$' \
|
||||
|| die "did not find test-unstable-2 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-3 -> 0.1.3 (-> v0.1.3)$' \
|
||||
|| die "did not find test-unstable-3 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-4 -> 0.1.4 (-> v0.1.4)$' \
|
||||
|| die "did not find test-unstable-4 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-5 -> 0.1.5 (-> v0.1.5)$' \
|
||||
|| die "did not find test-unstable-5 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-6 -> 0.1.6 (-> v0.1.6)$' \
|
||||
|| die "did not find test-unstable-6 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-7 -> 0.1.7 (-> v0.1.7)$' \
|
||||
|| die "did not find test-unstable-7 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-8 -> 0.1.8 (-> v0.1.8)$' \
|
||||
|| die "did not find test-unstable-8 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-9 -> 0.1.9 (-> v0.1.9)$' \
|
||||
|| die "did not find test-unstable-9 alias"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-10 -> 0.1.10 (-> v0.1.10)$' \
|
||||
|| die "did not find test-unstable-10 alias"
|
||||
|
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
# set clobber option in order to test that this does not produce any
|
||||
# incompatibilities
|
||||
setopt noclobber
|
||||
fi
|
||||
|
||||
nvm alias test-stable-1 0.0.2 || die '`nvm alias test-stable-1 0.0.2` failed'
|
||||
|
||||
OUTPUT="$(nvm alias test-stable-1 | strip_colors)"
|
||||
EXPECTED_OUTPUT='test-stable-1 -> 0.0.2 (-> v0.0.2)'
|
||||
echo "$OUTPUT" | \grep -F "$EXPECTED_OUTPUT" || die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2: got '$OUTPUT'"
|
||||
|
||||
nvm alias test-stable-1 0.0.1 || die '`nvm alias test-stable-1 0.0.1` failed'
|
||||
|
||||
OUTPUT="$(nvm alias test-stable-1 | strip_colors)"
|
||||
EXPECTED_OUTPUT='test-stable-1 -> 0.0.1 (-> v0.0.1)'
|
||||
echo "$OUTPUT" | \grep -F "$EXPECTED_OUTPUT" || die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1: got '$OUTPUT'"
|
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias | strip_colors)
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F "stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)" \
|
||||
|| die "nvm alias did not contain the default local stable node version; got '$NVM_ALIAS_OUTPUT'"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F "node -> stable (-> $STABLE_VERSION) (default)" \
|
||||
|| die "nvm alias did not contain the default local stable node version under 'node'; got '$NVM_ALIAS_OUTPUT'"
|
||||
|
||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F "unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)" \
|
||||
|| die "nvm alias did not contain the default local unstable node version; got '$NVM_ALIAS_OUTPUT'"
|
||||
|
||||
EXPECTED_IOJS="$(nvm_print_implicit_alias local iojs)"
|
||||
IOJS_VERSION="$(nvm_version "$EXPECTED_IOJS")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F "iojs -> $EXPECTED_IOJS (-> $IOJS_VERSION) (default)" \
|
||||
|| die "nvm alias did not contain the default local iojs version; got '$NVM_ALIAS_OUTPUT'"
|
@@ -1,49 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
cleanup () {
|
||||
rm -rf "$(nvm_alias_path)/stable"
|
||||
rm -rf "$(nvm_alias_path)/unstable"
|
||||
rm -rf "$(nvm_alias_path)/node"
|
||||
rm -rf "$(nvm_alias_path)/iojs"
|
||||
rm -rf "${NVM_DIR}/v0.8.1"
|
||||
rm -rf "${NVM_DIR}/v0.9.1"
|
||||
rm -rf "${NVM_DIR}/versions/io.js/v0.2.1"
|
||||
}
|
||||
|
||||
make_fake_node v0.8.1
|
||||
make_fake_node v0.9.1
|
||||
make_fake_iojs v0.2.1
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
|
||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
|
||||
[ "_$STABLE_VERSION" != "_$UNSTABLE_VERSION" ] \
|
||||
|| die "stable and unstable versions are the same!"
|
||||
|
||||
nvm alias stable "$EXPECTED_UNSTABLE"
|
||||
nvm alias unstable "$EXPECTED_STABLE"
|
||||
nvm alias node stable
|
||||
nvm alias iojs unstable
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias | strip_colors)
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -F "stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)" \
|
||||
|| die "nvm alias did not contain the overridden 'stable' alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -F "unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)" \
|
||||
|| die "nvm alias did not contain the overridden 'unstable' alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -F "node -> stable (-> $UNSTABLE_VERSION)" \
|
||||
|| die "nvm alias did not contain the overridden 'node' alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -F "iojs -> unstable (-> $STABLE_VERSION)" \
|
||||
|| die "nvm alias did not contain the overridden 'iojs' alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
|
||||
cleanup
|
@@ -1,48 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
NVM_ALIAS_OUTPUT="$(nvm alias | strip_colors)"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-1 -> 0.0.1 (-> v0.0.1)' \
|
||||
|| die "did not find test-stable-1 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-2 -> 0.0.2 (-> v0.0.2)' \
|
||||
|| die "did not find test-stable-2 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-3 -> 0.0.3 (-> v0.0.3)' \
|
||||
|| die "did not find test-stable-3 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-4 -> 0.0.4 (-> v0.0.4)' \
|
||||
|| die "did not find test-stable-4 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-5 -> 0.0.5 (-> v0.0.5)' \
|
||||
|| die "did not find test-stable-5 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-6 -> 0.0.6 (-> v0.0.6)' \
|
||||
|| die "did not find test-stable-6 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-7 -> 0.0.7 (-> v0.0.7)' \
|
||||
|| die "did not find test-stable-7 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-8 -> 0.0.8 (-> v0.0.8)' \
|
||||
|| die "did not find test-stable-8 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-9 -> 0.0.9 (-> v0.0.9)' \
|
||||
|| die "did not find test-stable-9 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-10 -> 0.0.10 (-> v0.0.10)' \
|
||||
|| die "did not find test-stable-10 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-1 -> 0.1.1 (-> v0.1.1)' \
|
||||
|| die "did not find test-unstable-1 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-2 -> 0.1.2 (-> v0.1.2)' \
|
||||
|| die "did not find test-unstable-2 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-3 -> 0.1.3 (-> v0.1.3)' \
|
||||
|| die "did not find test-unstable-3 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-4 -> 0.1.4 (-> v0.1.4)' \
|
||||
|| die "did not find test-unstable-4 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-5 -> 0.1.5 (-> v0.1.5)' \
|
||||
|| die "did not find test-unstable-5 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-6 -> 0.1.6 (-> v0.1.6)' \
|
||||
|| die "did not find test-unstable-6 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-7 -> 0.1.7 (-> v0.1.7)' \
|
||||
|| die "did not find test-unstable-7 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-8 -> 0.1.8 (-> v0.1.8)' \
|
||||
|| die "did not find test-unstable-8 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-9 -> 0.1.9 (-> v0.1.9)' \
|
||||
|| die "did not find test-unstable-9 alias; got '$NVM_ALIAS_OUTPUT'"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-unstable-10 -> 0.1.10 (-> v0.1.10)' \
|
||||
|| die "did not find test-unstable-10 alias; got '$NVM_ALIAS_OUTPUT'"
|
@@ -1,36 +1,36 @@
|
||||
#!/bin/sh
|
||||
\. ../../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
\. ../../../../nvm.sh
|
||||
. ../../../../nvm.sh
|
||||
|
||||
ALIAS="$(nvm_resolve_alias loopback | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_alias loopback)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias loopback was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias loopback | strip_colors)"
|
||||
OUTPUT="$(nvm alias loopback)"
|
||||
EXPECTED_OUTPUT="loopback -> loopback (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias loopback was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_alias one | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_alias one)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias one was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias one | strip_colors)"
|
||||
OUTPUT="$(nvm alias one)"
|
||||
EXPECTED_OUTPUT="one -> two (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias one was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_alias two | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_alias two)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias two was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias two | strip_colors)"
|
||||
OUTPUT="$(nvm alias two)"
|
||||
EXPECTED_OUTPUT="two -> three (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias two was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_alias three | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_alias three)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias three was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias three | strip_colors)"
|
||||
OUTPUT="$(nvm alias three)"
|
||||
EXPECTED_OUTPUT="three -> one (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias three was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_alias four | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_alias four)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias four was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias four | strip_colors)"
|
||||
OUTPUT="$(nvm alias four)"
|
||||
EXPECTED_OUTPUT="four -> two (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias four was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
|
@@ -1,36 +1,36 @@
|
||||
#!/bin/sh
|
||||
\. ../../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
\. ../../../../nvm.sh
|
||||
. ../../../../nvm.sh
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias loopback | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_local_alias loopback)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias loopback was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias loopback | strip_colors)"
|
||||
OUTPUT="$(nvm alias loopback)"
|
||||
EXPECTED_OUTPUT="loopback -> loopback (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias loopback was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias one | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_local_alias one)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias one was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias one | strip_colors)"
|
||||
OUTPUT="$(nvm alias one)"
|
||||
EXPECTED_OUTPUT="one -> two (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias one was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias two | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_local_alias two)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias two was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias two | strip_colors)"
|
||||
OUTPUT="$(nvm alias two)"
|
||||
EXPECTED_OUTPUT="two -> three (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias two was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias three | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_local_alias three)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias three was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias three | strip_colors)"
|
||||
OUTPUT="$(nvm alias three)"
|
||||
EXPECTED_OUTPUT="three -> one (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias three was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias four | strip_colors)"
|
||||
ALIAS="$(nvm_resolve_local_alias four)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias four was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias four | strip_colors)"
|
||||
OUTPUT="$(nvm alias four)"
|
||||
EXPECTED_OUTPUT="four -> two (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias four was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
|
@@ -7,3 +7,4 @@ echo three > ../../../../alias/two
|
||||
echo one > ../../../../alias/three
|
||||
|
||||
echo two > ../../../../alias/four
|
||||
|
||||
|
@@ -7,3 +7,4 @@ rm -f ../../../../alias/two
|
||||
rm -f ../../../../alias/three
|
||||
|
||||
rm -f ../../../../alias/four
|
||||
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
\. ../../../../nvm.sh
|
||||
\. ../../../common.sh
|
||||
|
||||
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"
|
||||
|
||||
rm -rf "${LTS_ALIAS_PATH}"
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
[ ! -d "${LTS_ALIAS_PATH}" ] || die "'${LTS_ALIAS_PATH}' exists and should not"
|
||||
|
||||
nvm alias >/dev/null 2>&1
|
||||
|
||||
[ -d "${LTS_ALIAS_PATH}" ] || die "'${LTS_ALIAS_PATH}' does not exist and should"
|
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../../nvm.sh
|
||||
|
||||
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"
|
||||
|
||||
if [ -d "${LTS_ALIAS_PATH}" ]; then
|
||||
mv "${LTS_ALIAS_PATH}" "${LTS_ALIAS_PATH}.bak"
|
||||
rm -rf "${LTS_ALIAS_PATH}"
|
||||
fi
|
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../../nvm.sh
|
||||
|
||||
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"
|
||||
|
||||
if [ -d "${LTS_ALIAS_PATH}.bak" ]; then
|
||||
rm -rf "${LTS_ALIAS_PATH}"
|
||||
mv "${LTS_ALIAS_PATH}.bak" "${LTS_ALIAS_PATH}"
|
||||
fi
|
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm alias default 0.1 >/dev/null || die "'nvm alias default 0.1' failed"
|
||||
|
||||
nvm_ensure_default_set 0.3 || die "'nvm_ensure_default_set' with an existing default alias exits 0"
|
||||
|
||||
nvm unalias default || die "'nvm unalias default' failed"
|
||||
|
||||
OUTPUT="$(nvm_ensure_default_set 0.2)"
|
||||
EXPECTED_OUTPUT="Creating default alias: default -> 0.2 (-> iojs-v0.2.10)"
|
||||
EXIT_CODE="$?"
|
||||
|
||||
[ "_$(echo "$OUTPUT" | strip_colors)" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set 0.2' did not output '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "'nvm_ensure_default_set 0.2' did not exit with 0, got $EXIT_CODE"
|
@@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
set -e
|
||||
|
||||
nvm_get_colors(){
|
||||
echo "0;95m"
|
||||
}
|
||||
|
||||
nvm_alias_path() {
|
||||
nvm_echo "../../../alias"
|
||||
}
|
||||
|
||||
OUTPUT=$(command printf %b $(nvm_list_aliases test-stable-1) | awk '{ print substr($0, 1, 19); }')
|
||||
|
||||
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1" | awk '{ print substr($0, 1, 19); }')
|
||||
echo "\033[0m"
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "nvm_list_aliases did not call nvm_get_colors. Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
@@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
echo "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
MOCKS_DIR="../Unit tests/mocks"
|
||||
|
||||
# sample output at the time the test was written
|
||||
TAB_PATH="$MOCKS_DIR/nodejs.org-dist-index.tab"
|
||||
nvm_download() {
|
||||
cat "$TAB_PATH"
|
||||
}
|
||||
|
||||
nvm_alias_path() {
|
||||
nvm_echo "../../../alias"
|
||||
}
|
||||
|
||||
nvm ls-remote >/dev/null || die 'nvm ls-remote (to populate LTS aliases) failed'
|
||||
|
||||
EXPECTED_OUTPUT="$(cat "$MOCKS_DIR/lts-star.txt")"
|
||||
STDOUT_OUTPUT="$(nvm_list_aliases "lts/*")"
|
||||
STDERR_OUTPUT="$(nvm_list_aliases "lts/*" 2>&1 >/dev/null)"
|
||||
|
||||
[ -z "${STDERR_OUTPUT}" ] || die "expected no stderr output, got >${STDERR_OUTPUT}<"
|
||||
[ "${STDOUT_OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected ${EXPECTED_OUTPUT}, got >${STDOUT_OUTPUT}<"
|
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
mv "$(nvm_alias_path)/_lts.bak" "$(nvm_alias_path)/lts"
|
||||
echo "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_alias_path() {
|
||||
nvm_echo "../../../alias"
|
||||
}
|
||||
|
||||
mv "$(nvm_alias_path)/lts" "$(nvm_alias_path)/_lts.bak"
|
||||
|
||||
STDERR_OUTPUT="$(nvm_list_aliases 2>&1 >/dev/null)"
|
||||
|
||||
[ -z "${STDERR_OUTPUT}" ] || die "expected no stderr output, got >${STDERR_OUTPUT}<"
|
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
# echo "$@" ;
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_get_colors(){
|
||||
echo "0;95m"
|
||||
}
|
||||
|
||||
# nvm_print_alias_path call nvm_print_formatted_alias which calls nvm_get-colors
|
||||
# the output of nvm_print_alias_path uses the color code returned by nvm_get_colors (redefined above)
|
||||
NVM_ALIAS_DIR='../../../alias'
|
||||
|
||||
OUTPUT=$(command printf %b $(nvm_print_alias_path "$NVM_ALIAS_DIR" "$NVM_ALIAS_DIR"/test-stable-1) | awk '{ print substr($0, 1, 24); }')
|
||||
|
||||
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1\033[0m")
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
|
||||
set +e
|
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
# # # expecting in red and two grays:
|
||||
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[0;31mfakealias\033[0m ")"
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
# expecting in bold yellow and two grays:
|
||||
nvm set-colors bbbYb
|
||||
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[1;33mfakealias\033[0m ")"
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
@@ -1,10 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
export NVM_DIR="$(cd ../../.. && pwd)"
|
||||
|
||||
\. "${NVM_DIR}/nvm.sh"
|
||||
. ../../../nvm.sh
|
||||
|
||||
EXIT_CODE=$(nvm_resolve_alias ; echo $?)
|
||||
[ $EXIT_CODE = "1" ] || die "nvm_resolve_alias without an argument did not return 1; got $EXIT_CODE"
|
||||
@@ -33,17 +31,3 @@ UNSTABLE="$(nvm_resolve_alias unstable)"
|
||||
|
||||
IOJS="$(nvm_resolve_alias iojs)"
|
||||
[ "_$IOJS" = "_iojs-v0.2" ] || die "'nvm_resolve_alias iojs' was not iojs-v0.2; got $IOJS"
|
||||
|
||||
echo "
|
||||
|
||||
v0.0.1
|
||||
v0.0.2
|
||||
v0.0.3
|
||||
" > ../../../alias/test-multi-lines
|
||||
|
||||
EXPECTED='v0.0.1'
|
||||
ACTUAL="$(nvm_resolve_alias test-multi-lines)"
|
||||
EXIT_CODE="$(nvm_resolve_alias test-multi-lines 2>&1 >/dev/null; echo $?)"
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}"
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
EXIT_CODE=$(nvm_resolve_local_alias ; echo $?)
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "nvm_resolve_local_alias without an argument did not return 1; got $EXIT_CODE"
|
||||
|
@@ -1,16 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
export NVM_DIR="$(cd ../../.. && pwd)"
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
for i in $(seq 1 10)
|
||||
do
|
||||
echo 0.0.$i > ../../../alias/test-stable-$i
|
||||
make_fake_node v0.0.$i
|
||||
mkdir -p ../../../v0.0.$i
|
||||
echo 0.1.$i > ../../../alias/test-unstable-$i
|
||||
make_fake_node v0.1.$i
|
||||
mkdir -p ../../../v0.1.$i
|
||||
echo 0.2.$i > ../../../alias/test-iojs-$i
|
||||
make_fake_iojs v0.2.$i
|
||||
mkdir -p ../../../versions/io.js/v0.2.$i
|
||||
done
|
||||
|
@@ -14,6 +14,3 @@ rm -f "../../../alias/stable"
|
||||
rm -f "../../../alias/unstable"
|
||||
rm -f "../../../alias/node"
|
||||
rm -f "../../../alias/iojs"
|
||||
rm -f "../../../alias/default"
|
||||
rm -f "../../../alias/test-blank-lines"
|
||||
rm -f "../../../alias/test-multi-lines"
|
||||
|
@@ -1,13 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
mkdir -p ../../../v0.0.2
|
||||
mkdir -p ../../../v0.0.20
|
||||
mkdir -p ../../../versions/node/v0.12.0
|
||||
|
||||
make_fake_node v0.0.2
|
||||
make_fake_node v0.0.20
|
||||
make_fake_node v0.12.0
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
# The result should contain only the appropriate version numbers.
|
||||
|
||||
@@ -25,3 +24,4 @@ nvm which 0.12.0 || die "v0.0.20 not found"
|
||||
NVM_BIN="$(nvm which 0.12.0)"
|
||||
[ "_$NVM_BIN" = "_$(nvm_version_path v0.12.0)/bin/node" ] \
|
||||
|| die "'nvm which 0.12.0' did not contain the correct path: got '$NVM_BIN'"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm which nonexistent_version
|
||||
[ "_$?" = "_1" ]
|
@@ -1,3 +1,3 @@
|
||||
rm -rf ../../../v0.0.2
|
||||
rm -rf ../../../v0.0.20
|
||||
rm -rf ../../../v0.12.0
|
||||
rmdir ../../../v0.0.2 >/dev/null 2>&1
|
||||
rmdir ../../../v0.0.20 >/dev/null 2>&1
|
||||
rmdir ../../../v0.12.0 >/dev/null 2>&1
|
||||
|
@@ -1,12 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
mkdir ../../../v0.0.2
|
||||
mkdir ../../../v0.0.20
|
||||
|
||||
make_fake_node v0.0.2
|
||||
make_fake_node v0.0.20
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
# The result should contain only the appropriate version numbers.
|
||||
|
||||
@@ -19,3 +18,4 @@ nvm ls 0.0.2 | grep 'v0.0.20' > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
die '"nvm ls 0.0.2" contained v0.0.20'
|
||||
fi
|
||||
|
@@ -1,13 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
mkdir ../../../v0.1.3
|
||||
mkdir ../../../v0.2.3
|
||||
mkdir ../../../v0.20.3
|
||||
|
||||
make_fake_node v0.1.3
|
||||
make_fake_node v0.2.3
|
||||
make_fake_node v0.20.3
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
# The result should contain only the appropriate version numbers.
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls nonexistent_version
|
||||
[ "$?" = "3" ]
|
||||
|
7
test/fast/Listing versions/Running "nvm ls io" should return NA
Executable file
7
test/fast/Listing versions/Running "nvm ls io" should return NA
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls io
|
||||
[ "$?" = "3" ]
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls node_
|
||||
[ "$?" = "3" ]
|
||||
|
@@ -1,12 +1,11 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
make_fake_node v0.2.3
|
||||
make_fake_node v0.3.3
|
||||
mkdir ../../../v0.2.3
|
||||
mkdir ../../../v0.3.3
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
@@ -20,10 +19,11 @@ nvm ls stable | \grep "$STABLE_VERSION" >/dev/null \
|
||||
nvm ls unstable | \grep "$UNSTABLE_VERSION" >/dev/null \
|
||||
|| die "expected 'nvm ls unstable' to give $UNSTABLE_VERSION, got $(nvm ls unstable)"
|
||||
|
||||
make_fake_node v0.1.4
|
||||
mkdir ../../../v0.1.2
|
||||
nvm alias stable 0.1
|
||||
|
||||
nvm ls stable | \grep -v "$STABLE_VERSION" >/dev/null \
|
||||
|| die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.4"
|
||||
nvm ls stable | \grep v0.1.4 >/dev/null \
|
||||
|| die "'nvm ls stable' did not contain v0.1.4"
|
||||
|| die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.2"
|
||||
nvm ls stable | \grep v0.1.2 >/dev/null \
|
||||
|| die "'nvm ls stable' did not contain v0.1.2"
|
||||
|
@@ -1,16 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
make_fake_node v0.0.1
|
||||
make_fake_node v0.0.3
|
||||
make_fake_node v0.0.9
|
||||
make_fake_node v0.3.1
|
||||
make_fake_node v0.3.3
|
||||
make_fake_node v0.3.9
|
||||
mkdir -p ../../../v0.0.1
|
||||
mkdir -p ../../../v0.0.3
|
||||
mkdir -p ../../../v0.0.9
|
||||
mkdir -p ../../../v0.3.1
|
||||
mkdir -p ../../../v0.3.3
|
||||
mkdir -p ../../../v0.3.9
|
||||
|
||||
nvm_has_system_node() { return 0; }
|
||||
nvm ls system | grep system 2>&1 > /dev/null
|
||||
@@ -19,3 +18,4 @@ nvm ls system | grep system 2>&1 > /dev/null
|
||||
nvm_has_system_node() { return 1; }
|
||||
nvm ls system | grep system 2>&1 > /dev/null
|
||||
[ $? -ne 0 ] || die '"nvm ls system" contained "system" when system node is not present'
|
||||
|
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
mkdir ../../../v0.0.1
|
||||
mkdir ../../../v0.0.3
|
||||
mkdir ../../../v0.0.9
|
||||
mkdir ../../../v0.3.1
|
||||
mkdir ../../../v0.3.3
|
||||
mkdir ../../../v0.3.9
|
||||
mkdir -p ../../../versions/node/v0.12.87
|
||||
mkdir -p ../../../versions/node/v0.12.9
|
||||
mkdir -p ../../../versions/io.js/v0.1.2
|
||||
mkdir -p ../../../versions/io.js/v0.10.2
|
||||
|
||||
# The result should contain the version numbers.
|
||||
nvm ls | grep v0.0.1 >/dev/null &&
|
||||
nvm ls | grep v0.0.3 >/dev/null &&
|
||||
nvm ls | grep v0.0.9 >/dev/null &&
|
||||
nvm ls | grep v0.3.1 >/dev/null &&
|
||||
nvm ls | grep v0.3.3 >/dev/null &&
|
||||
nvm ls | grep v0.3.9 >/dev/null &&
|
||||
nvm ls | grep v0.12.87 >/dev/null &&
|
||||
nvm ls | grep iojs-v0.1.2 >/dev/null
|
@@ -1,10 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
mkdir ../../../v0.1.3
|
||||
mkdir ../../../v0.2.3
|
||||
|
||||
make_fake_node v0.1.3
|
||||
make_fake_node v0.2.3
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ -z `nvm ls | grep '^ *\.'` ]
|
||||
# The result should contain only the appropriate version numbers.
|
@@ -1,10 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
mkdir ../../../v0.1.3
|
||||
mkdir ../../../v0.2.3
|
||||
mkdir -p ../../../versions/node
|
||||
|
||||
make_fake_node v0.1.3
|
||||
make_fake_node v0.2.3
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ -z "$(nvm ls | \grep 'versions')" ]
|
||||
# The result should contain only the appropriate version numbers.
|
||||
|
@@ -1,16 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
make_fake_node v0.0.1
|
||||
make_fake_node v0.0.3
|
||||
make_fake_node v0.0.9
|
||||
make_fake_node v0.3.1
|
||||
make_fake_node v0.3.3
|
||||
make_fake_node v0.3.9
|
||||
mkdir -p ../../../v0.0.1
|
||||
mkdir -p ../../../v0.0.3
|
||||
mkdir -p ../../../v0.0.9
|
||||
mkdir -p ../../../v0.3.1
|
||||
mkdir -p ../../../v0.3.3
|
||||
mkdir -p ../../../v0.3.9
|
||||
|
||||
nvm_has_system_node() { return 0; }
|
||||
nvm ls | grep system 2>&1 > /dev/null
|
||||
@@ -19,3 +18,4 @@ nvm ls | grep system 2>&1 > /dev/null
|
||||
nvm_has_system_node() { return 1; }
|
||||
nvm ls | grep system 2>&1 > /dev/null
|
||||
[ $? -ne 0 ] || die '"nvm ls" contained "system" when system node is not present'
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
mkdir -p ../../../versions/node/v0.12.1
|
||||
mkdir ../../../v0.1.3
|
||||
|
||||
make_fake_node v0.12.1
|
||||
make_fake_node v0.1.3
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls 0.12 | grep v0.12.1 || die '"nvm ls" did not list a version in the versions/ directory'
|
||||
nvm ls 0.1 | grep v0.1.3 || die '"nvm ls" did not list a version not in the versions/ directory'
|
||||
|
@@ -1,11 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
mkdir ../../../v0.1.2
|
||||
|
||||
make_fake_node v0.1.2
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls v0.1 | grep v0.1.2 &&
|
||||
nvm ls v0.1.2 | grep v0.1.2 &&
|
||||
nvm ls v0.1. | grep v0.1.2 &&
|
||||
nvm ls v0.1.1 | grep N/A
|
||||
|
@@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
|
||||
|
||||
make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made'
|
||||
make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made'
|
||||
make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made'
|
||||
make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made'
|
||||
|
||||
set -e
|
||||
|
||||
nvm_list_aliases() {
|
||||
echo 'sd-6'
|
||||
}
|
||||
# sanity check
|
||||
OUTPUT="$(nvm alias)"
|
||||
EXPECTED_OUTPUT='sd-6'
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
|
||||
nvm_ls() {
|
||||
echo v0.12.87
|
||||
echo v0.12.9
|
||||
echo iojs-v0.1.2
|
||||
echo iojs-v0.10.2
|
||||
}
|
||||
OUTPUT="$(nvm ls --no-colors --no-alias)"
|
||||
EXPECTED_OUTPUT=" v0.12.87 *
|
||||
v0.12.9 *
|
||||
iojs-v0.1.2 *
|
||||
iojs-v0.10.2 *"
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
|
||||
|
||||
set -e
|
||||
|
||||
OUTPUT="$(nvm ls --no-colors --no-alias pattern 2>&1 ||:)"
|
||||
EXPECTED_OUTPUT='`--no-alias` is not supported when a pattern is provided.'
|
||||
EXIT_CODE="$(nvm ls --no-colors --no-alias pattern >/dev/null 2>&1 || echo $?)"
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
|
||||
[ "${EXIT_CODE}" = 55 ] || die "expected 55; got >${EXIT_CODE}<"
|
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm ls io
|
||||
[ "$?" = "3" ]
|
@@ -1,35 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
|
||||
|
||||
make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made'
|
||||
make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made'
|
||||
make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made'
|
||||
make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made'
|
||||
|
||||
set -e
|
||||
|
||||
nvm_list_aliases() {
|
||||
echo 'sd-6'
|
||||
}
|
||||
# sanity check
|
||||
OUTPUT="$(nvm alias)"
|
||||
EXPECTED_OUTPUT='sd-6'
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
|
||||
nvm_ls() {
|
||||
echo v0.12.87
|
||||
echo v0.12.9
|
||||
echo iojs-v0.1.2
|
||||
echo iojs-v0.10.2
|
||||
}
|
||||
OUTPUT="$(nvm ls --no-colors)"
|
||||
EXPECTED_OUTPUT=" v0.12.87 *
|
||||
v0.12.9 *
|
||||
iojs-v0.1.2 *
|
||||
iojs-v0.10.2 *
|
||||
sd-6"
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
@@ -1,44 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
make_fake_node v0.0.1
|
||||
make_fake_node v0.0.3
|
||||
make_fake_node v0.0.9
|
||||
make_fake_node v0.3.1
|
||||
make_fake_node v0.3.3
|
||||
make_fake_node v0.3.9
|
||||
make_fake_node v0.12.87
|
||||
make_fake_node v0.12.9
|
||||
make_fake_iojs v0.1.2
|
||||
make_fake_iojs v0.10.2
|
||||
|
||||
# The result should contain the version numbers.
|
||||
nvm ls | grep v0.0.1 >/dev/null || die "v0.0.1 not found in: $(nvm ls)"
|
||||
nvm ls | grep v0.0.3 >/dev/null || die "v0.0.3 not found in: $(nvm ls)"
|
||||
nvm ls | grep v0.0.9 >/dev/null || die "v0.0.9 not found in: $(nvm ls)"
|
||||
nvm ls | grep v0.3.1 >/dev/null || die "v0.3.1 not found in: $(nvm ls)"
|
||||
nvm ls | grep v0.3.3 >/dev/null || die "v0.3.3 not found in: $(nvm ls)"
|
||||
nvm ls | grep v0.3.9 >/dev/null || die "v0.3.9 not found in: $(nvm ls)"
|
||||
nvm ls | grep v0.12.87 >/dev/null || die "v0.12.87 not found in: $(nvm ls)"
|
||||
nvm ls | grep iojs-v0.1.2 >/dev/null || die "iojs-v0.1.2 not found in: $(nvm ls)"
|
||||
|
||||
OUTPUT="$(nvm_ls)"
|
||||
EXPECTED_OUTPUT="v0.0.1
|
||||
v0.0.3
|
||||
v0.0.9
|
||||
iojs-v0.1.2
|
||||
v0.3.1
|
||||
v0.3.3
|
||||
v0.3.9
|
||||
iojs-v0.10.2
|
||||
v0.12.9
|
||||
v0.12.87"
|
||||
if nvm_has_system_node || nvm_has_system_iojs; then
|
||||
EXPECTED_OUTPUT="${EXPECTED_OUTPUT}
|
||||
system"
|
||||
fi
|
||||
[ "${OUTPUT-}" = "${EXPECTED_OUTPUT-}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
@@ -1,42 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
export NVM_DIR="$(cd ../../.. && pwd)"
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
if type setopt >/dev/null 2>&1; then setopt local_options markdirs; fi
|
||||
|
||||
die () {
|
||||
if type unsetopt >/dev/null 2>&1; then unsetopt local_options markdirs; fi
|
||||
echo "$@";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
make_fake_node v0.0.1
|
||||
make_fake_node v0.0.3
|
||||
make_fake_node v0.0.9
|
||||
make_fake_node v0.3.1
|
||||
make_fake_node v0.3.3
|
||||
make_fake_node v0.3.9
|
||||
make_fake_node v0.12.87
|
||||
make_fake_node v0.12.9
|
||||
make_fake_iojs v0.1.2
|
||||
make_fake_iojs v0.10.2
|
||||
|
||||
OUTPUT="$(nvm_ls)"
|
||||
EXPECTED_OUTPUT="v0.0.1
|
||||
v0.0.3
|
||||
v0.0.9
|
||||
iojs-v0.1.2
|
||||
v0.3.1
|
||||
v0.3.3
|
||||
v0.3.9
|
||||
iojs-v0.10.2
|
||||
v0.12.9
|
||||
v0.12.87"
|
||||
if nvm_has_system_node || nvm_has_system_iojs; then
|
||||
EXPECTED_OUTPUT="${EXPECTED_OUTPUT}
|
||||
system"
|
||||
fi
|
||||
[ "${OUTPUT-}" = "${EXPECTED_OUTPUT-}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
make_fake_node v0.12.34 || die 'fake v0.12.34 could not be made'
|
||||
|
||||
# Enable no unset variable
|
||||
set -u
|
||||
|
||||
# Try an alias that does not exist
|
||||
output=$(nvm ls 99 2>&1 1>/dev/null || true)
|
||||
test -z "${output}" || die "1: expected empty; got >${output}"
|
||||
|
||||
# Try a version that does not exist
|
||||
output=$(nvm ls 0.12.00 2>&1 1>/dev/null || true)
|
||||
test -z "${output}" || die "2: expected empty; got >${output}"
|
||||
|
||||
# Try a version that does exist
|
||||
output=$(nvm ls 0.12.34 2>&1 1>/dev/null || true)
|
||||
test -z "${output}" || die "3: expected empty; got >${output}"
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user