extract-from-argv 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/package.json +10 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/extract-from-argv-options.d.ts +4 -0
- package/src/lib/extract-from-argv-options.js +3 -0
- package/src/lib/extract-from-argv-options.js.map +1 -0
- package/src/lib/extract-from-argv.d.ts +8 -0
- package/src/lib/extract-from-argv.js +23 -0
- package/src/lib/extract-from-argv.js.map +1 -0
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +6 -0
- package/src/lib/index.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# extract-from-argv
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build extract-from-argv` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test extract-from-argv` to execute the unit tests via [Jest](https://jestjs.io).
|
package/package.json
ADDED
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/extract-from-argv/src/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-from-argv-options.js","sourceRoot":"","sources":["../../../../../libs/extract-from-argv/src/lib/extract-from-argv-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExtractFromArgvOptions } from './extract-from-argv-options';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts a given value from a list of arguments from 'process.argv'
|
|
4
|
+
* @param targetKey the variable key where the value should be extracted
|
|
5
|
+
* @param options options to provide a custom argv-list to extract from and other options
|
|
6
|
+
* @returns {string | null} the found value, null if the key was not found
|
|
7
|
+
*/
|
|
8
|
+
export declare const extractFromArgv: (targetKey: string, options?: ExtractFromArgvOptions) => string | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractFromArgv = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Extracts a given value from a list of arguments from 'process.argv'
|
|
6
|
+
* @param targetKey the variable key where the value should be extracted
|
|
7
|
+
* @param options options to provide a custom argv-list to extract from and other options
|
|
8
|
+
* @returns {string | null} the found value, null if the key was not found
|
|
9
|
+
*/
|
|
10
|
+
const extractFromArgv = (targetKey, options = {}) => {
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
options.argv = (_b = (_a = options.argv) !== null && _a !== void 0 ? _a : process.argv) !== null && _b !== void 0 ? _b : [];
|
|
13
|
+
options.valueSeparator = (_c = options.valueSeparator) !== null && _c !== void 0 ? _c : '=';
|
|
14
|
+
for (const arg of options.argv) {
|
|
15
|
+
const argvParts = options.valueSeparator ? arg.split(options.valueSeparator) : [arg];
|
|
16
|
+
if (argvParts[0] === targetKey) {
|
|
17
|
+
return (_d = argvParts[1]) !== null && _d !== void 0 ? _d : '';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
exports.extractFromArgv = extractFromArgv;
|
|
23
|
+
//# sourceMappingURL=extract-from-argv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-from-argv.js","sourceRoot":"","sources":["../../../../../libs/extract-from-argv/src/lib/extract-from-argv.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAE,UAAkC,EAAE,EAAiB,EAAE;;IACxG,OAAO,CAAC,IAAI,GAAG,MAAA,MAAA,OAAO,CAAC,IAAI,mCAAI,OAAO,CAAC,IAAI,mCAAI,EAAE,CAAC;IAClD,OAAO,CAAC,cAAc,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,GAAG,CAAC;IAEvD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE;QAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACrF,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;YAC9B,OAAO,MAAA,SAAS,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAC;SAC3B;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAZW,QAAA,eAAe,mBAY1B"}
|
package/src/lib/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractFromArgv = void 0;
|
|
4
|
+
var extract_from_argv_1 = require("./extract-from-argv");
|
|
5
|
+
Object.defineProperty(exports, "extractFromArgv", { enumerable: true, get: function () { return extract_from_argv_1.extractFromArgv; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/extract-from-argv/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAA7C,oHAAA,eAAe,OAAA"}
|