Last active
July 24, 2022 02:03
-
-
Save lilactown/b0cb983158dcf453f2ac058d23fbe44f to your computer and use it in GitHub Desktop.
Show a self-install nbb script by using a wrapper around nbb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
current_dir=$(pwd) | |
# make directory to hold node_modules | |
read -ra hash <<< "$(pwd | shasum)" # get hash of current path | |
modules_dir="$HOME/.nbb/_modules/${hash[0]}" | |
mkdir -p "$modules_dir" | |
# install node_modules | |
if [[ -z "${SKIP_INSTALL}" ]]; then | |
cd "$modules_dir" || exit | |
read -ra deps <<< "$1" # split deps into array | |
npm i "${deps[@]}" | |
cd "$current_dir" || exit | |
fi | |
shift # get rid of deps argument | |
NODE_PATH="$modules_dir/node_modules" npx nbb "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./runner [email protected] [email protected] | |
(ns script | |
(:require | |
["zx" :refer [$]])) | |
($ #js ["echo hi"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can invoke
./script.cljs
and it will automatically install any dependencies necessary to run it.You can also specify the env var
SKIP_INSTALL=true ./script.cljs
to avoid running npm install