Skip to content

Commit

Permalink
Fix type errors (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
avli authored Jun 15, 2018
1 parent 7fa159c commit 54404e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/cljConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const disconnect = (showMessage: boolean = true): void => {
vscode.window.showWarningMessage('Not connected to any nREPL.');
};

const getLocalNReplPort = (): number => {
const getLocalNReplPort = (): number | undefined => {
const projectDir = vscode.workspace.rootPath;

if (projectDir) {
Expand All @@ -164,7 +164,9 @@ const getLocalNReplPort = (): number => {
}

const homeDir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
return getPortFromFS(path.join(homeDir, '.lein', 'repl-port'));
if (homeDir) {
return getPortFromFS(path.join(homeDir, '.lein', 'repl-port'));
}
};

const getPortFromFS = (path: string): number => fs.existsSync(path) ? Number.parseInt(fs.readFileSync(path, 'utf-8')) : NaN;
Expand Down
13 changes: 10 additions & 3 deletions src/clojureEval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@ function runTests(outputChannel: vscode.OutputChannel, listener: TestListener, n

export function testNamespace(outputChannel: vscode.OutputChannel, listener: TestListener): void {
const editor = vscode.window.activeTextEditor;
const ns = cljParser.getNamespace(editor.document.getText()); // log ns and 'starting'
outputChannel.appendLine("Testing " + ns)
runTests(outputChannel, listener, ns);
if (editor) {
const text = editor.document.getText();
const ns = cljParser.getNamespace(text); // log ns and 'starting'
outputChannel.appendLine("Testing " + ns)
runTests(outputChannel, listener, ns);
} else {
// if having troubles with finding the namespace (though I'm not sure
// if it can actually happen), run all tests
runAllTests(outputChannel, listener);
}
}

export function runAllTests(outputChannel: vscode.OutputChannel, listener: TestListener): void {
Expand Down
4 changes: 2 additions & 2 deletions src/nreplClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const evaluateFile = (code: string, filepath: string, session?: string): Promise

const stacktrace = (session: string): Promise<any> => send({ op: 'stacktrace', session: session });

const runTests = function (namespace: string): Promise<any[]> {
const runTests = function (namespace: string | undefined): Promise<any[]> {
const message: TestMessage = {
op: (namespace ? "test" : "test-all"),
ns: namespace,
Expand All @@ -84,7 +84,7 @@ const runTests = function (namespace: string): Promise<any[]> {
}


const clone = (session?: string): Promise<any[]> => send({ op: 'clone', session: session }).then(respObjs => respObjs[0]);
const clone = (session?: string): Promise<string> => send({ op: 'clone', session: session }).then(respObjs => respObjs[0]);

const test = (connectionInfo: CljConnectionInformation): Promise<any[]> => {
return send({ op: 'clone' }, connectionInfo)
Expand Down

0 comments on commit 54404e6

Please sign in to comment.