@hugoalh/argv
v3.0.2
Published
A module to correctly slice off `process.argv`.
Downloads
14
Readme
Argv (NodeJS)
🆙 ()
A NodeJS module to correctly slice off process.argv
.
🎯 Target
- NodeJS >= v16.13.0
🔰 Usage
- 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>]
- Via NPM
- 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
propertyexports
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"
|