Skip to content

About

Run scripts with your AdonisJS app loaded

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

adonis-run

Run a script with your AdonisJS application booted, like rails runner.

node ace run scripts/release.ts

Read more here: Adding rails runner to AdonisJS.

Install

node ace add @antislop/adonis-run

This installs the package and registers its run command in adonisrc.ts:

commands: [
  // ... your existing commands

  // This will be added:
  () => import('@antislop/adonis-run/commands'),
],

Usage

Run a script like this:

node ace run scripts/release.ts

Arguments and flags

Extra arguments are passed through the script and available in process.argv.slice(2):

node ace run scripts/greet.ts Alice "Hello there"
// scripts/greet.ts
const [name, greeting] = process.argv.slice(2);
console.log(`${greeting}, ${name}!`);

Use -- before script flags so Ace does not interpret them:

node ace run scripts/release.ts production -- --dry-run --limit=10

The script receives ['production', '--dry-run', '--limit=10']. The first -- is a separator and is not forwarded. Arguments after it are preserved, including flag values, leading zeros, and additional -- tokens.

process.argv[0] remains the Node.js executable, and process.argv[1] is the resolved script path.

License

MIT

About

Run scripts with your AdonisJS app loaded

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages