Skip to content

Commit

Permalink
Remove @microsoft/typescript-etw dependency (#1351)
Browse files Browse the repository at this point in the history
Co-authored-by: Jackson Weber <[email protected]>
  • Loading branch information
hectorhdzg and JacksonWeber authored Jun 28, 2024
1 parent 1de7557 commit 6e0b8d3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/agent/diagnostics/writers/etwWritter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

import * as fs from 'fs';
import * as path from 'path';
import type * as etwTypes from '@microsoft/typescript-etw';
import { Util } from "../../../shared/util";
import { IAgentLogger } from "../../types";

export class EtwWritter implements IAgentLogger {
private _etwModule: typeof etwTypes | undefined;
private _etwModule: any;

constructor() {
const nodeMajVer = parseInt(process.versions.node.split('.')[0], 10);
Expand Down Expand Up @@ -46,14 +45,14 @@ export class EtwWritter implements IAgentLogger {
}
}

private _loadEtwModule(nodeMajVer: number): typeof etwTypes | undefined {
private _loadEtwModule(nodeMajVer: number){
// Try to load precompiled ETW module if it exists and is "importable"
const dirname = path.join(__dirname, '../../../../../../../etw', `etw_${nodeMajVer}`);
try {
// throws an error if directory is not readable / does not exist
fs.accessSync(dirname, fs.constants.R_OK);
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require(dirname) as typeof etwTypes;
return require(dirname);
} catch (e) {
// Could not load ETW, return nothing
return undefined;
Expand Down

0 comments on commit 6e0b8d3

Please sign in to comment.