Skip to content

Instantly share code, notes, and snippets.

View ryanpback's full-sized avatar
Drinking coffee and punching keys

Ryan Back ryanpback

Drinking coffee and punching keys
View GitHub Profile
@ryanpback
ryanpback / autoload-nvm
Last active August 20, 2022 20:15
NVM Autoload
# This is how I've managed to make this work with the least amount of lag time.
# load-nvm from NVM checks the node version every time you cd into another directory which causes noticeable delays.
# This version will get your current working directory and traverse each directory looking for a `.nvmrc` file until it reaches your current directory.
# Once it finds the closest directory with a `.nvmrc` file, it will store that version in a variable `$NVM_VERSION_TO_USE`.
# Next is to hook into the preexec hook. If the command you're running starts with yarn, npm, or node (could maybe check others as well - any command that would invoke node),
# it will then set the node version using NVM.
# Running a yarn command has its own delay (install, test, start, etc.) so the small lag before the yarn command is negligable.
# It will also only set the node version once so long as you haven't switched directories, so subsequent invoking of yarn is quick.
{
"name": "online-store",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",