mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
vscode: simplify assert.eq() to assert() as per matklad
This commit is contained in:
parent
e7bf99e6fd
commit
6dc598fa63
@ -19,11 +19,10 @@ export async function downloadArtifact(
|
|||||||
installationDir: string,
|
installationDir: string,
|
||||||
displayName: string,
|
displayName: string,
|
||||||
) {
|
) {
|
||||||
await fs.mkdir(installationDir).catch(err => assert.eq(
|
await fs.mkdir(installationDir).catch(err => assert(
|
||||||
err?.code,
|
err?.code === "EEXIST",
|
||||||
"EEXIST",
|
|
||||||
`Couldn't create directory "${installationDir}" to download ` +
|
`Couldn't create directory "${installationDir}" to download ` +
|
||||||
`${artifactFileName} artifact: ${err.message}`
|
`${artifactFileName} artifact: ${err?.message}`
|
||||||
));
|
));
|
||||||
|
|
||||||
const installationPath = path.join(installationDir, artifactFileName);
|
const installationPath = path.join(installationDir, artifactFileName);
|
||||||
|
@ -2,7 +2,7 @@ import * as lc from "vscode-languageclient";
|
|||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import { strict as nativeAssert } from "assert";
|
import { strict as nativeAssert } from "assert";
|
||||||
|
|
||||||
export function assert(condition: unknown, explanation: string): asserts condition {
|
export function assert(condition: boolean, explanation: string): asserts condition {
|
||||||
try {
|
try {
|
||||||
nativeAssert(condition, explanation);
|
nativeAssert(condition, explanation);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -11,16 +11,6 @@ export function assert(condition: unknown, explanation: string): asserts conditi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.eq = <T>(bibba: unknown, bobba: T, explanation: string): asserts bibba is T => {
|
|
||||||
try {
|
|
||||||
nativeAssert.strictEqual(bibba, bobba, explanation);
|
|
||||||
} catch (err) {
|
|
||||||
log.error(`Equality assertion failed:`, explanation);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export const log = {
|
export const log = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
debug(message?: any, ...optionalParams: any[]): void {
|
debug(message?: any, ...optionalParams: any[]): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user