Skip to content

Instantly share code, notes, and snippets.

@ruyaoyao
Forked from bellbind/.profile
Created December 18, 2019 10:17
Show Gist options
  • Save ruyaoyao/f4fccf6c1f07f85accd4d82cfbb3ecb3 to your computer and use it in GitHub Desktop.
Save ruyaoyao/f4fccf6c1f07f85accd4d82cfbb3ecb3 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 "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment