@hugoalh/argv
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

Argv (NodeJS)

⚖️ MIT

🗂️ GitHub: hugoalh-studio/argv-nodejs NPM: @hugoalh/argv

🆙 Latest Release Version (Latest Release Date)

A NodeJS module to correctly slice off process.argv.

🎯 Target

  • NodeJS >= v16.13.0

🔰 Usage

  1. Install via console/shell/terminal:
    • Via NPM
      npm install @hugoalh/argv[@<Tag>]
    • Via PNPM
      pnpm add @hugoalh/argv[@<Tag>]
    • Via Yarn
      yarn add @hugoalh/argv[@<Tag>]
  2. Import at the script (<ScriptName>.js):
    import ... from "@hugoalh/argv";

    ℹ️ Note

    Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit file package.json property exports for available sub paths.

🧩 API

  • const args: string;// Additional command line arguments.
  • const binIndex: 0 | 1;// Index of bin in `process.argv`.
  • const binPath: string;// Path of the file is execute.
  • const isBundledElectronJSProgram: boolean;// Whether the process is execute from bundled ElectronJS program.
  • const isElectronJSProgram: boolean;// Whether the process is execute from ElectronJS program.
  • const isUnbundledElectronJSProgram: boolean;// Whether the process is execute from unbundled ElectronJS program.
  • const programPath: string;// Path of the executable file is execute.

✍️ Example

argv.________ node bin.js args1 args2 ...argsn bin args1 args2 ...argsn electron bin.js args1 args2 ...argsn
args ["args1", "args2", ..., "argsn"] ["args1", "args2", ..., "argsn"] ["args1", "args2", ..., "argsn"]
binIndex 1 0 1
binPath "/path-to/bin.js" "/path-to/bin" "/path-to/bin.js"
isBundledElectronJSProgram false true false
isElectronJSProgram false true true
isUnbundledElectronJSProgram false false true
programPath "/path-to/node" "/path-to/bin" "/path-to/electron"

Readme

Keywords

Package Sidebar

Install

npm i @hugoalh/argv

Weekly Downloads

1

Version

3.0.2

License

MIT

Unpacked Size

8.24 kB

Total Files

6

Last publish

Collaborators

  • hugoalh