Atlas › Test

helpers.mjs|title=helpers hideBin hides bin for standard node.js application|occurrence=1

Exact test identity: mocha:v1|namespace=yargs@4153e0f097aeaf43a71a2530db6dda51dff2c544:esm|file=test/esm/helpers.mjs|title=helpers hideBin hides bin for standard node.js application|occurrence=1

Package
mocha:v1|namespace=yargs@4153e0f097aeaf43a71a2530db6dda51dff2c544:esm|file=test/esm
Suite / test hierarchy
helpers.mjs|title=helpers hideBin hides bin for standard node.js application|occurrence=1
Test
helpers.mjs|title=helpers hideBin hides bin for standard node.js application|occurrence=1
Introduced at
helpers.mjs|title=helpers hideBin hides bin for standard node.js application|occurrence=1 Frontier kind: Test frontier
Covered ranges
16
Covered lines
47
Covered files
3

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

lib/utils/process-argv.ts 34 covered LOC · 10 ranges

Open complete file

1 > function getProcessArgvBinIndex() { process-argv.ts
2 > // The binary name is the first command line argument for:
3 > // - bundled Electron apps: bin argv1 argv2 ... argvn
4 > if (isBundledElectronApp()) return 0;
5 > // or the second one (default) for: process-argv.ts
6 > // - standard node apps: node bin.js argv1 argv2 ... argvn
7 > // - unbundled Electron apps: electron bin.js argv1 arg2 ... argvn
8 > return 1;
9 > }
11 > function isBundledElectronApp() { process-argv.ts
12 > // process.defaultApp is either set by electron in an electron unbundled app, or undefined
13 > // see https://github.com/electron/electron/blob/main/docs/api/process.md#processdefaultapp-readonly
14 > return isElectronApp() && !(process as ElectronProcess).defaultApp;
15 > }
17 > function isElectronApp() { process-argv.ts
18 > // process.versions.electron is either set by electron, or undefined
19 > // see https://github.com/electron/electron/blob/main/docs/api/process.md#processversionselectron-readonly
20 > return !!(process as ElectronProcess).versions.electron;
21 > }
23 > export function hideBin(argv: string[]) {
24 > return argv.slice(getProcessArgvBinIndex() + 1); process-argv.ts
25 > }
27 > export function getProcessArgvBin() {
28 return process.argv[getProcessArgvBinIndex()];
29 }
31 > interface ElectronProcess extends NodeJS.Process {
32 > defaultApp?: boolean;
33 > versions: NodeJS.ProcessVersions & {
34 > electron: string;
35 > };
36 > }
lib/utils/apply-extends.ts 9 covered LOC · 4 ranges

Open complete file

1 > import {Dictionary, PlatformShim} from '../typings/common-types.js'; apply-extends.ts
2 > import {YError} from '../yerror.js';
3 >
4 > let previouslyVisitedConfigs: string[] = [];
5 > let shim: PlatformShim;
6 > export function applyExtends(
7 config: Dictionary,
8 cwd: string,
51 : Object.assign({}, defaultConfig, config);
52 }
54 function checkForCircularExtends(cfgPath: string) {
55 if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) {
57 }
58 }
60 function getPathToDefaultConfig(cwd: string, pathToExtend: string) {
61 return shim.path.resolve(cwd, pathToExtend);
62 }
64 function mergeDeep(config1: Dictionary, config2: Dictionary) {
65 const target: Dictionary = {};
lib/yerror.ts 4 covered LOC · 2 ranges

Open complete file

1 > export class YError extends Error { yerror.ts
2 > name = 'YError';
3 > constructor(msg?: string | null) {
4 super(msg || 'yargs error');
5 if (Error.captureStackTrace) {