Skip to content

Commit

Permalink
Tweak file naming and use output.log()
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Jan 17, 2025
1 parent 388980e commit 7b84918
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions editors/code/src/binary.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import * as vscode from "vscode";
import which from "which";
import * as output from "./output";
import { AIR_BINARY_NAME, BUNDLED_AIR_EXECUTABLE } from "./constants";
import { outputLog } from "./logging";

export type ExecutableLocation = "environment" | "bundled";

export async function resolveAirBinaryPath(
executableLocation: ExecutableLocation
): Promise<string> {
if (!vscode.workspace.isTrusted) {
outputLog(
output.log(
`Workspace is not trusted, using bundled executable: ${BUNDLED_AIR_EXECUTABLE}`
);
return BUNDLED_AIR_EXECUTABLE;
}

// User requested the bundled air binary
if (executableLocation === "bundled") {
outputLog(
output.log(
`Using bundled executable as requested by \`air.executableLocation\`: ${BUNDLED_AIR_EXECUTABLE}`
);
return BUNDLED_AIR_EXECUTABLE;
Expand All @@ -26,11 +26,11 @@ export async function resolveAirBinaryPath(
// First choice: the executable in the global environment.
const environmentPath = await which(AIR_BINARY_NAME, { nothrow: true });
if (environmentPath) {
outputLog(`Using environment executable: ${environmentPath}`);
output.log(`Using environment executable: ${environmentPath}`);
return environmentPath;
}

// Second choice: bundled executable.
outputLog(`Using bundled executable: ${BUNDLED_AIR_EXECUTABLE}`);
output.log(`Using bundled executable: ${BUNDLED_AIR_EXECUTABLE}`);
return BUNDLED_AIR_EXECUTABLE;
}
2 changes: 1 addition & 1 deletion editors/code/src/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as lc from "vscode-languageclient/node";
import { default as PQueue } from "p-queue";
import { getInitializationOptions, getWorkspaceSettings } from "./settings";
import { Middleware, ResponseError } from "vscode-languageclient/node";
import { registerLogger } from "./logging";
import { registerLogger } from "./output";
import { resolveAirBinaryPath } from "./binary";
import { getRootWorkspaceFolder } from "./workspace";

Expand Down
6 changes: 3 additions & 3 deletions editors/code/src/logging.ts → editors/code/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Arguments = unknown[];
class OutputChannelLogger {
constructor(private readonly channel: OutputChannel) {}

public outputLog(...data: Arguments): void {
public log(...data: Arguments): void {
this.channel.appendLine(util.format(...data));
}
}
Expand All @@ -26,9 +26,9 @@ export function registerLogger(logChannel: OutputChannel): Disposable {
* Adapted from:
* https://github.com/microsoft/vscode-python-tools-extension-template/blob/main/src/common/log/logging.ts
*/
export function outputLog(...args: Arguments): void {
export function log(...args: Arguments): void {
if (process.env.CI === "true") {
console.log(...args);
}
channel?.outputLog(...args);
channel?.log(...args);
}

0 comments on commit 7b84918

Please sign in to comment.