Skip to content

Instantly share code, notes, and snippets.

@steve-ross steve-ross/.direnvrc
Last active Nov 14, 2017

Embed
What would you like to do?
Some Useful direnv.net helpers
install_nvm(){
log_status "Installing NVM"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
nvm install
}
npm_install(){
local HAS_NODE_MODULES_BIN=$(find node_modules/.bin)
if [ -z "$HAS_NODE_MODULES_BIN" ]; then
# didn't find it
npm install
else
layout_node
fi
}
load_or_install_nvm(){
local NVM_PATH=$(find_up .nvm/nvm.sh)
if [ -z "$NVM_PATH" ]; then
# didn't find it
install_nvm
fi
[ -s "$NVM_PATH" ] && . "$NVM_PATH" # This loads nvm
}
direnv_nvm_use_node(){
local NVM_PATH=$(find_up .nvm/nvm.sh)
# load version direnv way
local NVM_NODE_VERSION_DIR=versions/node
local NODE_VERSION=$(< .nvmrc)
local NVM_PATH="${NVM_PATH/nvm.sh/$NVM_NODE_VERSION_DIR}"
export NODE_VERSIONS=$NVM_PATH
export NODE_VERSION_PREFIX="v"
use node
}
requires_nvm(){
load_or_install_nvm
if has nvm; then
local version=$(< .nvmrc)
local nvmrc_node_version=$(nvm version "$version")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
else
direnv_nvm_use_node
fi
fi
# install node modules if needed
npm_install
}
config_or_init_stencil(){
local STENCIL_CONFIG=$(find .stencil)
if [ -z "$STENCIL_CONFIG" ]; then
stencil init
else
log_status "Good to go, 'stencil start' for local development"
fi
}
requires_stencil(){
if has stencil; then
log_status "Stencil Found"
config_or_init_stencil
else
log_status "Installing package contents"
npm install
config_or_init_stencil
fi
}
requires_themekit(){
if has theme; then
log_status "Found shopify themekit"
else
log_status "installing shopify themekit"
brew tap shopify/shopify
brew install themekit
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.