Running
Introduction
The CLI application of Athenna can run in three ways. Using the node artisan
, the npm scripts inside package.json file
or linking the package.json using npm link
, this way you can execute your CLI anywhere from your terminal. As node artisan
and npm scripts comes by default in your application, we are going to focus in npm link
in this documentation.
Registering your CLI command
To register your CLI command name you can simply add the bin
object inside your package.json file:
"bin": {
"yourCliCommand": "./bootstrap/main.js"
}
Entrypoint file
In our example we defined the ./bootstrap/main.js
file as the entrypoint file of our CLI. By default, this file
comes with the #!/usr/bin/env node
in the top of the file. Without this line the npm link
command will not work.
So just in case you want to define a different entrypoint file, remember that #!/usr/bin/env node
should be on the top
of this file.
Linking the package.json
Now you just need to run the following command in your project root:
npm link
And now the yourCliCommand
will exist in your actual Node.js version:
yourCliCommand --help