yalla-exec

0.0.17 • Public • Published

Yalla-Exec

Build Status JavaScript Style Guide MIT Licence npm version

Manage commands alongside environment variables. Use configuration file.

Instructions

Install using

npm install -g yalla-exec

Create a file named .yalla.

Add configuration such as

module.exports = {
  demo : {
    cmd: 'echo hello ${YALLA_USERNAME}',
    env: {
      YALLA_USERNAME: 'YALLA!!'
    }
  }
}

Run command

yalla demo

You should see this output

hello YALLA!

Other configurations

Yalla also supports configuration in yaml, json and inside package.json

For yaml and json the filename should still be .yalla

Example - yaml

demo:
  cmd: 'echo hello'

Exmple - json

{
  "demo":{
    "cmd": "echo hello"
  }
}

and inside pakcage.json simply add a yalla property

{
  "name": "my-module",
  "version" : "0.0.0",
  "dependencies": {},
  "yalla": {
    "demo": {
      "cmd": "echo hello"
    }
  }
}

another option: directory .yalla - expected to only contain configuration files

List all commands

To get a list of all possible commands in the configuration you can simply run yalla in the command line

> yalla
demo

Passing flags from outside

Yalla uses minimist and lodash template to allow you to pass flags from outside

So for example the following definition

start:
  cmd: <%= argv.watch ? 'nodemon' : 'node' %> server.js

Allows you to pass the flag watch and run nodemon server.js instead of node server.js

The syntax <%= argv.watch %> is from lodash's template mechanism and the reference to argv and its structure is from minimist library syntax

Yalla exposes minimist's arguments on the variable argv for the template.

This combination allows you to easily declare different variations to your commands. It also allows defining lists and complex objects from your command line.

yalla --config.db_url="..." --config.cors_regex="..."

Will result in argv.config = { db_url: '...' , cors_regex: '...'}

FAQ

Where are my colors?

When I run the command directly - I see colors, but with yalla the colors are gone.. Why is that?

Answer

The reason this happens is some libraries auto-detect if the terminal (yalla in this case) supports color. To force colors, just add environment variable export FORCE_COLOR=1

See relevant thread: https://github.com/Marak/colors.js/issues/127

Changelist

  • October 4 2020 - add support for directories.

Roadmap

  • support directories

  • support object values for environment variables

  • support JSON & Yaml configurations

  • support passing flags from outside and declaring required/optional flags (especially for debug)

  • make it a legit npm library. with github links, automated testing on a CI and license.

  • support yalla files in parent directories

  • support alternative working directories for commands

  • support 'watch' ability

  • support running multiple commands

    • so just an array of of commands should be enough.. we can silence the output with > /dev/null

Readme

Keywords

Package Sidebar

Install

npm i yalla-exec

Weekly Downloads

1

Version

0.0.17

License

MIT

Unpacked Size

14 kB

Total Files

12

Last publish

Collaborators

  • guy.mograbi