DEV Community

Cover image for ⚙️ ❮ Gems & Node Modules With ZI ❯
❮ ZI ❯ for Z-Shell

Posted on

⚙️ ❮ Gems & Node Modules With ZI ❯



Logo

https://z.digitalclouds.dev | GitHub | Twitter


With use of the bin-gem-node annex you can install Ruby Gems and Node modules in an interesting way:

  • they'll be installed in the plugin's or snippet's directory,
  • an automatic function will be provided to run the binary that's provided by the package.

This has several benefits. For example, no $PATH alteration is required in the .zprofile file. Also, the package will be automatically updated on zi update. Plus, the installation will be isolated from other packages – multiple packages not be put in a single place.

An example ZI invocation that installs the remark tool that can be used to convert Markdown documents into man pages:

zi ice wait'2' lucid id-as'remark' node'remark <- !remark-cli; remark-man'
zi snippet /dev/null

It is snippet-based. An example plugin-based invocation:

zi ice wait'2' lucid id-as'remark' node'remark <- !remark-cli; remark-man'
zi load z-shell/null

It has an advantage – it will delete the remark function when unloading the plugin.

The exclamation-mark before !remark-cli is important – it causes the automatic function invoking the binary to be created.

More information can be found on the bin-gem-node annex page.

The command installs 2 node modules – remark-cli and remark-man (the backend for the remark converter – remark can convert also to other formats).

By using the exclamation-mark and the <- pointer it also requests the function that will run the remark binary to be created. The function has the following body:

remark () {
    local bindir="/root/.zi/plugins/remark/node_modules/.bin"
        local -x NODE_PATH="/root/.zi/plugins/remark2"/node_modules
        "$bindir"/"remark" "$@"
}

As it can be seen it ultimately provides the remark tool to the command line.

Discussion (0)