Skip to content

Instantly share code, notes, and snippets.

@bellbind
Last active December 18, 2019 10:17
Show Gist options
  • Save bellbind/ecdd141d574bd7ba207a68ace1884394 to your computer and use it in GitHub Desktop.
Save bellbind/ecdd141d574bd7ba207a68ace1884394 to your computer and use it in GitHub Desktop.
[nodejs][nvm] bash function of node with full `Intl` locales support by automatic installing the prebuilt "icu4c-data" package
[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh # This loads NVM
function node {
rawnode=$(which node)
icu4cdata=$(dirname $(dirname $rawnode))/lib/node_modules/icu4c-data
[[ -d $icu4cdata ]] || npm install -g icu4c-data@$($rawnode -e '
console.log((v => v.icu_ver_major + v.icu_endianness)(
process.config.variables));')
NODE_ICU_DATA=$icu4cdata $rawnode "$@"
}
@mirabilos
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment