Skip to content

Commit 56e8369

Browse files
committed
1 parent 4968e0a commit 56e8369

8 files changed

Lines changed: 114 additions & 12 deletions

File tree

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"iconv-lite": "0.5.0",
3636
"jschardet": "1.6.0",
3737
"keytar": "^4.11.0",
38-
"minimist": "1.2.0",
3938
"native-is-elevated": "0.3.0",
4039
"native-keymap": "2.0.0",
4140
"native-watchdog": "1.0.0",
@@ -47,6 +46,7 @@
4746
"sudo-prompt": "9.0.0",
4847
"v8-inspect-profiler": "^0.0.20",
4948
"vscode-chokidar": "2.1.7",
49+
"vscode-minimist": "^1.2.1",
5050
"vscode-proxy-agent": "0.4.0",
5151
"vscode-ripgrep": "^1.5.5",
5252
"vscode-sqlite3": "4.0.8",
@@ -60,7 +60,6 @@
6060
"devDependencies": {
6161
"7zip": "0.0.6",
6262
"@types/keytar": "^4.4.0",
63-
"@types/minimist": "^1.2.0",
6463
"@types/mocha": "2.2.39",
6564
"@types/node": "^10.12.12",
6665
"@types/semver": "^5.5.0",
@@ -158,4 +157,4 @@
158157
"windows-mutex": "0.3.0",
159158
"windows-process-tree": "0.2.4"
160159
}
161-
}
160+
}

src/typings/vscode-minimist.d.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Type definitions for minimist 1.2.0
2+
// Project: https://github.com/substack/minimist
3+
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Necroskillz <https://github.com/Necroskillz>, kamranayub <https://github.com/kamranayub>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+
/**
7+
* Return an argument object populated with the array arguments from args
8+
*
9+
* @param args An optional argument array (typically `process.argv.slice(2)`)
10+
* @param opts An optional options object to customize the parsing
11+
*/
12+
declare function minimist(args?: string[], opts?: minimist.Opts): minimist.ParsedArgs;
13+
14+
/**
15+
* Return an argument object populated with the array arguments from args. Strongly-typed
16+
* to be the intersect of type T with minimist.ParsedArgs.
17+
*
18+
* @type T The type that will be intersected with minimist.ParsedArgs to represent the argument object
19+
* @param args An optional argument array (typically `process.argv.slice(2)`)
20+
* @param opts An optional options object to customize the parsing
21+
*/
22+
declare function minimist<T>(args?: string[], opts?: minimist.Opts): T & minimist.ParsedArgs;
23+
24+
/**
25+
* Return an argument object populated with the array arguments from args. Strongly-typed
26+
* to be the the type T which should extend minimist.ParsedArgs
27+
*
28+
* @type T The type that extends minimist.ParsedArgs and represents the argument object
29+
* @param args An optional argument array (typically `process.argv.slice(2)`)
30+
* @param opts An optional options object to customize the parsing
31+
*/
32+
declare function minimist<T extends minimist.ParsedArgs>(args?: string[], opts?: minimist.Opts): T;
33+
34+
declare namespace minimist {
35+
export interface Opts {
36+
/**
37+
* A string or array of strings argument names to always treat as strings
38+
*/
39+
string?: string | string[];
40+
41+
/**
42+
* A boolean, string or array of strings to always treat as booleans. If true will treat
43+
* all double hyphenated arguments without equals signs as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
44+
*/
45+
boolean?: boolean | string | string[];
46+
47+
/**
48+
* An object mapping string names to strings or arrays of string argument names to use as aliases
49+
*/
50+
alias?: { [key: string]: string | string[] };
51+
52+
/**
53+
* An object mapping string argument names to default values
54+
*/
55+
default?: { [key: string]: any };
56+
57+
/**
58+
* When true, populate argv._ with everything after the first non-option
59+
*/
60+
stopEarly?: boolean;
61+
62+
/**
63+
* A function which is invoked with a command line parameter not defined in the opts
64+
* configuration object. If the function returns false, the unknown option is not added to argv
65+
*/
66+
unknown?: (arg: string) => boolean;
67+
68+
/**
69+
* When true, populate argv._ with everything before the -- and argv['--'] with everything after the --.
70+
* Note that with -- set, parsing for arguments still stops after the `--`.
71+
*/
72+
'--'?: boolean;
73+
}
74+
75+
export interface ParsedArgs {
76+
[arg: string]: any;
77+
78+
/**
79+
* If opts['--'] is true, populated with everything after the --
80+
*/
81+
'--'?: string[];
82+
83+
/**
84+
* Contains all the arguments that didn't have an option associated with them
85+
*/
86+
_: string[];
87+
}
88+
}
89+
90+
declare module "vscode-minimist" {
91+
export = minimist;
92+
}

src/vs/platform/environment/node/argv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as minimist from 'minimist';
6+
import * as minimist from 'vscode-minimist';
77
import * as os from 'os';
88
import { localize } from 'vs/nls';
99
import { ParsedArgs } from 'vs/platform/environment/common/environment';

src/vs/platform/environment/test/node/environmentService.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,15 @@ suite('EnvironmentService', () => {
5252
assert.equal(parse(['--user-data-dir', './dir'], { cwd: () => '/foo', env: { 'VSCODE_CWD': '/bar' } }), path.resolve('/bar/dir'),
5353
'should use VSCODE_CWD as the cwd when --user-data-dir is specified');
5454
});
55+
56+
// https://github.com/microsoft/vscode/issues/78440
57+
test.only('careful with boolean file names', function () {
58+
let actual = parseArgs(['-r', 'arg.txt']);
59+
assert(actual['reuse-window']);
60+
assert.deepEqual(actual._, ['arg.txt']);
61+
62+
actual = parseArgs(['-r', 'true.txt']);
63+
assert(actual['reuse-window']);
64+
assert.deepEqual(actual._, ['true.txt']);
65+
});
5566
});

src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as nativeWatchdog from 'native-watchdog';
77
import * as net from 'net';
8-
import * as minimist from 'minimist';
8+
import * as minimist from 'vscode-minimist';
99
import { onUnexpectedError } from 'vs/base/common/errors';
1010
import { Event, Emitter } from 'vs/base/common/event';
1111
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc';

src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as assert from 'assert';
7-
import * as minimist from 'minimist';
7+
import * as minimist from 'vscode-minimist';
88
import * as path from 'vs/base/common/path';
99
import { CancellationToken } from 'vs/base/common/cancellation';
1010
import { URI } from 'vs/base/common/uri';

src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ISearchService } from 'vs/workbench/services/search/common/search';
1313
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
1414
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
1515
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
16-
import * as minimist from 'minimist';
16+
import * as minimist from 'vscode-minimist';
1717
import * as path from 'vs/base/common/path';
1818
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
1919
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@
112112
resolved "https://registry.yarnpkg.com/@types/keytar/-/keytar-4.4.0.tgz#ca24e6ee6d0df10c003aafe26e93113b8faf0d8e"
113113
integrity sha512-cq/NkUUy6rpWD8n7PweNQQBpw2o0cf5v6fbkUVEpOB9VzzIvyPvSEId1/goIj+MciW2v1Lw5mRimKO01XgE9EA==
114114

115-
"@types/minimist@^1.2.0":
116-
version "1.2.0"
117-
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
118-
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
119-
120115
"@types/mocha@2.2.39":
121116
version "2.2.39"
122117
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.39.tgz#f68d63db8b69c38e9558b4073525cf96c4f7a829"
@@ -9546,6 +9541,11 @@ vscode-fsevents@1.2.12:
95469541
dependencies:
95479542
nan "^2.14.0"
95489543

9544+
vscode-minimist@^1.2.1:
9545+
version "1.2.1"
9546+
resolved "https://registry.yarnpkg.com/vscode-minimist/-/vscode-minimist-1.2.1.tgz#e63d3f4a9bf3680dcb8f9304eed612323fd6926a"
9547+
integrity sha512-cmB72+qDoiCFJ1UKnGUBdGYfXzdpJ3bQM/D/+XhkVk5v7uZgLbYiCz5JcwVyk7NC7hSi5VGtQ4wihzmi12NeXw==
9548+
95499549
vscode-nls-dev@^3.3.1:
95509550
version "3.3.1"
95519551
resolved "https://registry.yarnpkg.com/vscode-nls-dev/-/vscode-nls-dev-3.3.1.tgz#15fc03e0c9ca5a150abb838690d9554ac06f77e4"

0 commit comments

Comments
 (0)