Skip to content

Commit 5690a47

Browse files
committed
remove lodash dependency
fixes microsoft#19438
1 parent e0537cb commit 5690a47

8 files changed

Lines changed: 50 additions & 22747 deletions

File tree

extensions/git/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@
351351
},
352352
"dependencies": {
353353
"denodeify": "^1.2.1",
354-
"lodash": "^4.17.2",
355354
"vscode-nls": "^2.0.1"
356355
}
357356
}

extensions/git/src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class CommandCenter {
103103
message = localize('clean repo', "Please clean your repository working tree before checkout.");
104104
break;
105105
default:
106-
message = (err.stderr || err.message).replace(/^error: /, '');
106+
message = (err.stderr || err.message || String(err)).replace(/^error: /, '');
107107
break;
108108
}
109109

extensions/git/src/git.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import * as path from 'path';
1010
import * as os from 'os';
1111
import * as cp from 'child_process';
1212
import * as denodeify from 'denodeify';
13-
import { IDisposable, toDisposable, dispose } from './util';
14-
import * as _ from 'lodash';
13+
import { assign, uniqBy, groupBy, IDisposable, toDisposable, dispose } from './util';
1514
import { EventEmitter, Event } from 'vscode';
1615
import * as nls from 'vscode-nls';
1716

@@ -292,12 +291,12 @@ export class Git {
292291
}
293292

294293
async exec(cwd: string, args: string[], options: any = {}): Promise<IExecutionResult> {
295-
options = _.assign({ cwd }, options || {});
294+
options = assign({ cwd }, options || {});
296295
return await this._exec(args, options);
297296
}
298297

299298
stream(cwd: string, args: string[], options: any = {}): cp.ChildProcess {
300-
options = _.assign({ cwd }, options || {});
299+
options = assign({ cwd }, options || {});
301300
return this.spawn(args, options);
302301
}
303302

@@ -357,7 +356,7 @@ export class Git {
357356
options.stdio = ['ignore', null, null]; // Unless provided, ignore stdin and leave default streams for stdout and stderr
358357
}
359358

360-
options.env = _.assign({}, process.env, options.env || {});
359+
options.env = assign({}, process.env, options.env || {});
361360

362361
if (options.log !== false) {
363362
this.log(`git ${args.join(' ')}\n`);
@@ -394,22 +393,22 @@ export class Repository {
394393

395394
// TODO@Joao: rename to exec
396395
async run(args: string[], options: any = {}): Promise<IExecutionResult> {
397-
options.env = _.assign({}, options.env || {});
398-
options.env = _.assign(options.env, this.env);
396+
options.env = assign({}, options.env || {});
397+
options.env = assign(options.env, this.env);
399398

400399
return await this.git.exec(this.repository, args, options);
401400
}
402401

403402
stream(args: string[], options: any = {}): cp.ChildProcess {
404-
options.env = _.assign({}, options.env || {});
405-
options.env = _.assign(options.env, this.env);
403+
options.env = assign({}, options.env || {});
404+
options.env = assign(options.env, this.env);
406405

407406
return this.git.stream(this.repository, args, options);
408407
}
409408

410409
spawn(args: string[], options: any = {}): cp.ChildProcess {
411-
options.env = _.assign({}, options.env || {});
412-
options.env = _.assign(options.env, this.env);
410+
options.env = assign({}, options.env || {});
411+
options.env = assign(options.env, this.env);
413412

414413
return this.git.spawn(args, options);
415414
}
@@ -573,11 +572,9 @@ export class Repository {
573572
}
574573

575574
async clean(paths: string[]): Promise<void> {
576-
const tasks = _(paths)
577-
.groupBy(p => path.dirname(p))
578-
.values<string[]>()
579-
.map(paths => () => this.run(['clean', '-f', '-q', '--'].concat(paths)))
580-
.value();
575+
const pathsByGroup = groupBy(paths, p => path.dirname(p));
576+
const groups = Object.keys(pathsByGroup).map(k => pathsByGroup[k]);
577+
const tasks = groups.map(paths => () => this.run(['clean', '-f', '-q', '--'].concat(paths)));
581578

582579
for (let task of tasks) {
583580
await task();
@@ -802,14 +799,13 @@ export class Repository {
802799
async getRemotes(): Promise<IRemote[]> {
803800
const result = await this.run(['remote', '--verbose']);
804801
const regex = /^([^\s]+)\s+([^\s]+)\s/;
805-
806-
return _(result.stdout.trim().split('\n'))
802+
const rawRemotes = result.stdout.trim().split('\n')
807803
.filter(b => !!b)
808804
.map(line => regex.exec(line))
809805
.filter(g => !!g)
810-
.map((groups: RegExpExecArray) => ({ name: groups[1], url: groups[2] }))
811-
.uniqBy(remote => remote.name)
812-
.value();
806+
.map((groups: RegExpExecArray) => ({ name: groups[1], url: groups[2] }));
807+
808+
return uniqBy(rawRemotes, remote => remote.name);
813809
}
814810

815811
async getBranch(name: string): Promise<IBranch> {

extensions/git/src/typings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"globalDependencies": {
3-
"denodeify": "registry:dt/denodeify#1.2.1+20160316155526",
4-
"lodash": "registry:dt/lodash#4.14.0+20161110215204"
3+
"denodeify": "registry:dt/denodeify#1.2.1+20160316155526"
54
}
65
}

0 commit comments

Comments
 (0)