mirror of
https://github.com/tj/n.git
synced 2024-11-21 18:48:57 +01:00
Add --cleanup (#818)
This commit is contained in:
parent
cf40ac5e0a
commit
65bd2fe237
14
README.md
14
README.md
@ -60,7 +60,7 @@ To take ownership of the system directories (option 1):
|
||||
|
||||
If `npm` is not yet available, one way to bootstrap an install is to download and run `n` directly. To install the `lts` version of Node.js:
|
||||
|
||||
curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts
|
||||
curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s install lts
|
||||
# If you want n installed, you can use npm now.
|
||||
npm install -g n
|
||||
|
||||
@ -237,6 +237,18 @@ Use `n` to access cached versions (already downloaded) without internet availabl
|
||||
|
||||
n --offline 12
|
||||
|
||||
Remove the cache version after installing using `--cleanup`. This is particularly useful for a one-shot install, like in a docker container.
|
||||
|
||||
curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s install --cleanup lts
|
||||
|
||||
The `--download` option can be used in two ways, to download a version into cache but not make active:
|
||||
|
||||
n --download lts
|
||||
|
||||
or to download a possibly missing version for `n run`, `n exec`, and `n which`:
|
||||
|
||||
n --download run 18.3 my-script.js
|
||||
|
||||
Display diagnostics to help resolve problems:
|
||||
|
||||
n doctor
|
||||
|
9
bin/n
9
bin/n
@ -133,6 +133,7 @@ g_active_node=
|
||||
g_target_node=
|
||||
|
||||
DOWNLOAD=false # set to opt-out of activate (install), and opt-in to download (run, exec)
|
||||
CLEANUP=false # remove cached download after install
|
||||
ARCH=
|
||||
SHOW_VERBOSE_LOG="true"
|
||||
OFFLINE=false
|
||||
@ -397,6 +398,7 @@ Options:
|
||||
-p, --preserve Preserve npm and npx during install of Node.js
|
||||
-q, --quiet Disable curl output. Disable log messages processing "auto" and "engine" labels.
|
||||
-d, --download Download if necessary, and don't make active
|
||||
--cleanup Remove cached version after install
|
||||
-a, --arch Override system architecture
|
||||
--offline Resolve target version against cached downloads instead of internet lookup
|
||||
--all ls-remote displays all matches instead of last 20
|
||||
@ -757,6 +759,12 @@ activate() {
|
||||
printf 'If "node --version" shows the old version then start a new shell, or reset the location hash with:\nhash -r (for bash, zsh, ash, dash, and ksh)\nrehash (for csh and tcsh)\n'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CLEANUP" == "true" ]]; then
|
||||
log "cleanup" "removing cached $version"
|
||||
remove_versions "$version"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
@ -1672,6 +1680,7 @@ while [[ $# -ne 0 ]]; do
|
||||
-h|--help|help) display_help; exit ;;
|
||||
-q|--quiet) set_quiet ;;
|
||||
-d|--download) DOWNLOAD="true" ;;
|
||||
--cleanup) CLEANUP="true" ;;
|
||||
--offline) OFFLINE="true" ;;
|
||||
--insecure) set_insecure ;;
|
||||
-p|--preserve) N_PRESERVE_NPM="true" N_PRESERVE_COREPACK="true" ;;
|
||||
|
Loading…
Reference in New Issue
Block a user