paint-brush
Executing any Node.js module or .js file via CLI without creating any command-line interface at allby@DiegoZoracKy
7,465 reads
7,465 reads

Executing any Node.js module or .js file via CLI without creating any command-line interface at all

by Diego ZoracKyJanuary 5th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Recently I published <a href="https://github.com/DiegoZoracKy/magicli" target="_blank">MagiCLI</a>, which is a module built to create automagically a <a href="https://hackernoon.com/tagged/cli" target="_blank">CLI</a> for any given module. It's just needed to include it as a dependency, require the module, and then a CLI is ready. However, even though this tool is there, to be used, if a developer (end user) wants to execute some existing module published on npm via CLI, there was still a dependency. The maintainer of a module have to include <a href="https://hackernoon.com/tagged/magicli" target="_blank">MagiCLI</a> in order to provide the command-line interface. Well, not anymore 😉.
featured image - Executing any Node.js module or .js file via CLI without creating any command-line interface at all
Diego ZoracKy HackerNoon profile picture

Recently I published MagiCLI, which is a module built to create automagically a CLI for any given module. It's just needed to include it as a dependency, require the module, and then a CLI is ready. However, even though this tool is there, to be used, if a developer (end user) wants to execute some existing module published on npm via CLI, there was still a dependency. The maintainer of a module have to include MagiCLI in order to provide the command-line interface. Well, not anymore 😉.

MagiCLI can now be used to execute any module or .js file (containing module.exports) via CLI. Just install it as a global module (or call it using npx) and pass the path to a module or file as an argument. Check the docs to know better about its Usage via CLI.