Skip to content

Commit 2480214

Browse files
committed
Respond to code review feedback
1 parent f6f9d64 commit 2480214

File tree

7 files changed

+25
-50
lines changed

7 files changed

+25
-50
lines changed

gulpfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const tslint = require('gulp-tslint');
1414
const vsce = require('vsce');
1515
const debugUtil = require('./out/src/coreclr-debug/util');
1616
const debugInstall = require('./out/src/coreclr-debug/install');
17-
const fs_extra = require('fs-extra-promise');
1817
const packages = require('./out/src/packages');
1918
const logger = require('./out/src/logger');
2019
const platform = require('./out/src/platform');

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
]
9292
},
9393
{
94-
"description": "OmniSharp (.NET Core - OSX / x64)",
94+
"description": "OmniSharp (.NET Core - macOS / x64)",
9595
"url": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-1.9-beta19-osx-x64-netcoreapp1.0.zip",
9696
"installPath": ".omnisharp-coreclr",
9797
"runtimeIds": [
@@ -200,7 +200,7 @@
200200
]
201201
},
202202
{
203-
"description": ".NET Core Debugger (OSX / x64)",
203+
"description": ".NET Core Debugger (macOS / x64)",
204204
"url": "https://vsdebugger.azureedge.net/coreclr-debug-1-5-0/coreclr-debug-osx.10.11-x64.zip",
205205
"installPath": ".debugger",
206206
"runtimeIds": [

src/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export function getExtensionPath() {
2121
return extensionPath;
2222
}
2323

24+
export function getBinPath() {
25+
return path.resolve(getExtensionPath(), "bin");
26+
}
27+
2428
export function buildPromiseChain<T, TResult>(array: T[], builder: (item: T) => Promise<TResult>): Promise<TResult> {
2529
return array.reduce(
2630
(promise, n) => promise.then(() => builder(n)),
@@ -75,6 +79,7 @@ export function touchInstallFile(type: InstallFileType): Promise<void> {
7579
fs.writeFile(getInstallFilePath(type), '', err => {
7680
if (err) {
7781
reject(err);
82+
return;
7883
}
7984

8085
resolve();
@@ -87,6 +92,7 @@ export function deleteInstallFile(type: InstallFileType): Promise<void> {
8792
fs.unlink(getInstallFilePath(type), err => {
8893
if (err) {
8994
reject(err);
95+
return;
9096
}
9197

9298
resolve();

src/coreclr-debug/activate.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ import * as debugInstall from './install';
1212
import * as path from 'path';
1313
import { Logger } from './../logger'
1414

15-
let _util: CoreClrDebugUtil = null;
15+
let _debugUtil: CoreClrDebugUtil = null;
1616
let _reporter: TelemetryReporter = null;
1717
let _logger: Logger = null;
1818

1919
export function activate(context: vscode.ExtensionContext, reporter: TelemetryReporter, logger: Logger) {
20-
_util = new CoreClrDebugUtil(context.extensionPath, logger);
20+
_debugUtil = new CoreClrDebugUtil(context.extensionPath, logger);
2121
_reporter = reporter;
2222
_logger = logger;
2323

24-
if (!CoreClrDebugUtil.existsSync(_util.debugAdapterDir())) {
24+
if (!CoreClrDebugUtil.existsSync(_debugUtil.debugAdapterDir())) {
2525
// We have been activated but it looks like our package was not installed. This is bad.
2626
logger.appendLine("[ERROR]: C# Extension failed to install the debugger package");
2727
showInstallErrorMessage();
28-
} else if (!CoreClrDebugUtil.existsSync(_util.installCompleteFilePath())) {
29-
_util.checkDotNetCli()
28+
} else if (!CoreClrDebugUtil.existsSync(_debugUtil.installCompleteFilePath())) {
29+
_debugUtil.checkDotNetCli()
3030
.then((dotnetInfo: DotnetInfo) => {
31-
let installer = new debugInstall.DebugInstaller(_util);
31+
let installer = new debugInstall.DebugInstaller(_debugUtil);
3232
installer.finishInstall()
3333
.then(() => {
3434
vscode.window.setStatusBarMessage('Successfully installed .NET Core Debugger.');
@@ -42,7 +42,7 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
4242
}, (err) => {
4343
// Check for dotnet tools failed. pop the UI
4444
// err is a DotNetCliError but use defaults in the unexpected case that it's not
45-
showDotnetToolsWarning(err.ErrorMessage || _util.defaultDotNetCliErrorMessage());
45+
showDotnetToolsWarning(err.ErrorMessage || _debugUtil.defaultDotNetCliErrorMessage());
4646
_logger.appendLine(err.ErrorString || err);
4747
// TODO: log telemetry?
4848
});

src/coreclr-debug/install.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export class InstallError extends Error {
4242

4343
export class DebugInstaller {
4444
private _util: CoreClrDebugUtil = null;
45-
// private _isOffline;
4645

4746
constructor(util: CoreClrDebugUtil) {
4847
this._util = util;

src/coreclr-debug/util.ts

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as path from 'path';
99
import * as fs from 'fs';
1010
import * as os from 'os';
1111
import * as semver from 'semver';
12+
import { execChildProcess } from './../common'
1213
import { Logger } from './../logger'
1314

1415
const MINIMUM_SUPPORTED_DOTNET_CLI: string = '1.0.0-preview2-003121';
@@ -79,13 +80,14 @@ export class CoreClrDebugUtil
7980
// This function checks for the presence of dotnet on the path and ensures the Version
8081
// is new enough for us.
8182
// Returns: a promise that returns a DotnetInfo class
82-
// Throws: An CotNetCliError() from the return promise if either dotnet does not exist or is too old.
83+
// Throws: An DotNetCliError() from the return promise if either dotnet does not exist or is too old.
8384
public checkDotNetCli(): Promise<DotnetInfo>
8485
{
8586
let dotnetInfo = new DotnetInfo();
8687

87-
return this.spawnChildProcess('dotnet', ['--info'], process.cwd(), (data: Buffer) => {
88-
let lines: string[] = data.toString().replace(/\r/mg, '').split('\n');
88+
return execChildProcess('dotnet --info', process.cwd())
89+
.then((data: string) => {
90+
let lines: string[] = data.replace(/\r/mg, '').split('\n');
8991
lines.forEach(line => {
9092
let match: RegExpMatchArray;
9193
if (match = /^\ Version:\s*([^\s].*)$/.exec(line)) {
@@ -116,38 +118,6 @@ export class CoreClrDebugUtil
116118
});
117119
}
118120

119-
public spawnChildProcess(process: string, args: string[], workingDirectory: string, onStdout?: (data: Buffer) => void, onStderr?: (data: Buffer) => void): Promise<void> {
120-
const promise = new Promise<void>((resolve, reject) => {
121-
const child = child_process.spawn(process, args, { cwd: workingDirectory });
122-
123-
if (!onStdout) {
124-
onStdout = (data) => { console.log(`${data}`); };
125-
}
126-
child.stdout.on('data', onStdout);
127-
128-
if (!onStderr) {
129-
onStderr = (data) => { console.error(`${data}`); };
130-
}
131-
child.stderr.on('data', onStderr);
132-
133-
child.on('close', (code: number) => {
134-
if (code != 0) {
135-
console.log(`${process} exited with error code ${code}`);;
136-
reject(new Error(code.toString()));
137-
}
138-
else {
139-
resolve();
140-
}
141-
});
142-
143-
child.on('error', (error: Error) => {
144-
reject(error);
145-
});
146-
});
147-
148-
return promise;
149-
}
150-
151121
public static existsSync(path: string) : boolean {
152122
try {
153123
fs.accessSync(path, fs.F_OK);

src/main.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ function installRuntimeDependencies(extension: vscode.Extension<any>, logger: Lo
101101
installationStage = 'touchLockFile';
102102
return util.touchInstallFile(util.InstallFileType.Lock);
103103
})
104-
.then(() => {
105-
installationStage = 'deleteBeginFile';
106-
return util.deleteInstallFile(util.InstallFileType.Begin)
107-
})
108104
.catch(error => {
109105
errorMessage = error.toString();
110106
logger.appendLine(`Failed at stage: ${installationStage}`);
@@ -118,6 +114,11 @@ function installRuntimeDependencies(extension: vscode.Extension<any>, logger: Lo
118114
// TODO: Send telemetry event
119115

120116
statusItem.dispose();
117+
})
118+
.then(() => {
119+
// We do this step at the end so that we clean up the begin file in the case that we hit above catch block
120+
// Attach a an empty catch to this so that errors here do not propogate
121+
return util.deleteInstallFile(util.InstallFileType.Begin).catch((error) => { });
121122
});
122123
}
123124

0 commit comments

Comments
 (0)