Nondeterministic Polynomial Munchies
    Have ideas to improve npm?Join in the discussion! »

    magic-carpet

    0.0.2 • Public • Published

    npm version Build Status

    Magic Carpet

    Takes care of running your javascript npm-scripts and includes tools to make js shell scripts work like magic.

    Inspired by scripty

    Install

    npm install magic-carpet

    Usage

    1. From your module's root, create a scripts directory
    2. If you want to define an npm script named "magic:command", write an executable file at scripts/magic/command.js
    3. Declare your "magic:command" script in "scripts" in your package.json:
    {
      "scripts": {
        "foo:bar": "magic-carpet"
      }
    }
    1. Run the magic:command
    npm magic:command

    Shell helpers

    runAndExit

    The runAndExit can be helpful when running simple shell commands one after the other.

    const { runAndExit } = require('../');
     
    runAndExit(`
      echo "Magic Carpet"
      && cross-env NODE_ENV=test mocha
        --reporter=dot
        --config=.mocharc-e2e.js
        --public=src
      && yarn lint
    `);

    shellArguments

    If for any reason you need to get the shell arguments passed to yarn and pass them along to the apps you are calling then you can do that by using the shellArguments helper in the javascript shell application

    const { runAndExit, shellArguments } = require('pontus-scripts-runner');
     
    runAndExit(`
      yarn workspace workspace-name start ${shellArguments()}
    `);

    npmCommand

    The utility npmCommand will get the full npm or yarn command name being invoked. This can be useful when printing help screens.

    const { runAndExit, npmCommand } = require('pontus-scripts-runner');
     
    if {process.argv.includes('--help'){
      console.log(`
        ${npmCommand()}
     
        Some other helpfull information
      `.trim());
      process.exit(0);
    }
     
    runAndExit(`
      echo "normal operation"
    `);

    Install

    npm i magic-carpet

    DownloadsWeekly Downloads

    416

    Version

    0.0.2

    License

    none

    Unpacked Size

    7.74 kB

    Total Files

    22

    Last publish

    Collaborators

    • avatar