yargs 18.0.0-browser.0 → 18.0.0-candidate.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/build/lib/command.js
CHANGED
|
@@ -4,6 +4,7 @@ import { applyMiddleware, commandMiddlewareFactory, } from './middleware.js';
|
|
|
4
4
|
import { parseCommand } from './parse-command.js';
|
|
5
5
|
import { isYargsInstance, } from './yargs-factory.js';
|
|
6
6
|
import { maybeAsyncResult } from './utils/maybe-async-result.js';
|
|
7
|
+
import { readdirSync } from 'node:fs';
|
|
7
8
|
import { join, dirname } from 'node:path';
|
|
8
9
|
const DEFAULT_MARKER = /(^\*)|(^\$0)/;
|
|
9
10
|
export class CommandInstance {
|
|
@@ -21,14 +22,14 @@ export class CommandInstance {
|
|
|
21
22
|
opts = opts || {};
|
|
22
23
|
this.requireCache.add(callerFile);
|
|
23
24
|
const fullDirPath = join(dirname(callerFile), dir);
|
|
24
|
-
const files =
|
|
25
|
+
const files = readdirSync(fullDirPath, {
|
|
25
26
|
recursive: opts.recurse ? true : false,
|
|
26
27
|
});
|
|
27
28
|
if (!Array.isArray(opts.extensions))
|
|
28
29
|
opts.extensions = ['js'];
|
|
29
30
|
const visit = typeof opts.visit === 'function' ? opts.visit : (o) => o;
|
|
30
31
|
for (const fileb of files) {
|
|
31
|
-
const file = fileb.toString();
|
|
32
|
+
const file = fileb.toString('utf8');
|
|
32
33
|
if (opts.exclude) {
|
|
33
34
|
let exclude = false;
|
|
34
35
|
if (typeof opts.exclude === 'function') {
|
|
@@ -13,10 +13,9 @@ _{{app_name}}_yargs_completions()
|
|
|
13
13
|
args=("\${COMP_WORDS[@]}")
|
|
14
14
|
|
|
15
15
|
# ask yargs to generate completions.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }')
|
|
16
|
+
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
|
|
17
|
+
|
|
18
|
+
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
|
|
20
19
|
|
|
21
20
|
# if no match was found, fall back to filename completion
|
|
22
21
|
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
import cliui from 'https://unpkg.com/cliui@
|
|
5
|
-
import Parser from 'https://unpkg.com/yargs-parser@
|
|
4
|
+
import cliui from 'https://unpkg.com/cliui@7.0.1/index.mjs'; // eslint-disable-line
|
|
5
|
+
import Parser from 'https://unpkg.com/yargs-parser@19.0.0/browser.js'; // eslint-disable-line
|
|
6
6
|
import {getProcessArgvBin} from '../../build/lib/utils/process-argv.js';
|
|
7
7
|
import {YError} from '../../build/lib/yerror.js';
|
|
8
8
|
|
|
@@ -54,9 +54,6 @@ export default {
|
|
|
54
54
|
readFileSync: () => {
|
|
55
55
|
return '';
|
|
56
56
|
},
|
|
57
|
-
readdirSync: () => {
|
|
58
|
-
return [];
|
|
59
|
-
},
|
|
60
57
|
require: () => {
|
|
61
58
|
throw new YError(REQUIRE_ERROR);
|
|
62
59
|
},
|
|
@@ -4,6 +4,7 @@ import { notStrictEqual, strictEqual } from 'assert'
|
|
|
4
4
|
import cliui from 'cliui'
|
|
5
5
|
import escalade from 'escalade/sync'
|
|
6
6
|
import { inspect } from 'util'
|
|
7
|
+
import { readFileSync } from 'fs'
|
|
7
8
|
import { fileURLToPath } from 'url';
|
|
8
9
|
import Parser from 'yargs-parser'
|
|
9
10
|
import { basename, dirname, extname, relative, resolve } from 'path'
|
|
@@ -12,7 +13,6 @@ import stringWidth from 'string-width';
|
|
|
12
13
|
import y18n from 'y18n'
|
|
13
14
|
import { createRequire } from 'node:module';
|
|
14
15
|
import getCallerFile from 'get-caller-file';
|
|
15
|
-
import { readFileSync, readdirSync } from 'node:fs'
|
|
16
16
|
|
|
17
17
|
const __dirname = fileURLToPath(import.meta.url);
|
|
18
18
|
const mainFilename = __dirname.substring(0, __dirname.lastIndexOf('node_modules'));
|
|
@@ -52,7 +52,6 @@ export default {
|
|
|
52
52
|
stdColumns: typeof process.stdout.columns !== 'undefined' ? process.stdout.columns : null
|
|
53
53
|
},
|
|
54
54
|
readFileSync,
|
|
55
|
-
readdirSync,
|
|
56
55
|
require,
|
|
57
56
|
getCallerFile: () => {
|
|
58
57
|
const callerFile = getCallerFile(3);
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "18.0.0-
|
|
3
|
+
"version": "18.0.0-candidate.1",
|
|
4
4
|
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
|
5
5
|
"main": "./index.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
|
8
8
|
"./helpers": "./helpers/helpers.mjs",
|
|
9
9
|
"./browser": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"import": "./browser.mjs",
|
|
11
|
+
"types": "./browser.d.ts"
|
|
12
12
|
},
|
|
13
13
|
".": "./index.mjs",
|
|
14
14
|
"./yargs": "./index.mjs"
|