🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

xargv

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xargv

Node package runner with ability to pass foreign args

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

Xargv

Node package runner with ability to pass foreign args.

Code quality Coverage Greenkeeper badge CricleCi badge

npm version Open issues Types: TypeScript License: MIT

Main features

  • run any node cli tool with additional args
  • passes unknown args as env variable to the e.g. underlying config scripts
  • Typescript types included
  • exposes esm/cjs modules
  • always 100% test coverage

Guide

Installation

npm install --save xargv

or

yarn add xargv

or

pnpm --save xargv

Basic usage

Imagine a situation: you want to dynamically generate webpack config (webpack.config.js) based on provided args but webpack cli blocks you from passing any foreign values.

Below you will find way to deal with it.

Set argv config in the config file

In the root of the project provide .xargvrc file:

{
      // command name matches first ath passed to xargv
      "webpack": {
        // this is the path to cli you want to execute
        "binPath": "webpack/bin",
        // this is the env variable name all your extra args will be placed in
        "containerName": "ARGVX",
        // want to pass to xargv command args without --name? Thats the map of keys
        // for this values
        "unnamedArgKeys": [
            "unnamedA",
            "unnamedB"
        ],
        // thats the list of all args passed that should be passed as foreign vars
        "foreignKeys": [
            "unnamedA",
            "defaultA",
            "flagA",
            "inlineA"
        ],
        // This are args you dont want to define all over the package.json
        // did you noticed one of this values will endup as foreign var? Neat!
        "defaultArgs": {
            "defaultA": "defaultValueA",
            "defaultB": "defaultValueB"
        }
    }
}

Keep in mind you can define same config in the package.json file:

{
    [...]
    "xargv": {
        [...]
    }
}

As soon as you have config defined use it in one of the npm script's:

{
    [...]
    "scripts": {
        "start": "xargv webpack foreignValue nativeValue --nativeFlag --nativeInline nativeInlineValue nativeUnmatchedValue"
    }
}

Or via cli if you have installed package globally:

xargv webpack foreignValue nativeValue --nativeFlag --nativeInline nativeInlineValue nativeUnmatchedValue

For working examples please take a look at the repos example dir.

Documentation

Full API documentation for this package can be found here

FAQs

Package last updated on 10 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts