Skip to content

Fix GH#18217 issue for FileLog. #27430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Oct 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/typingsInstaller/nodeTypingsInstaller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// tslint:disable no-unnecessary-type-assertion (TODO: tslint can't find node types)

namespace ts.server.typingsInstaller {
const fs: {
appendFileSync(file: string, content: string): void
Expand All @@ -12,19 +10,20 @@ namespace ts.server.typingsInstaller {
} = require("path");

class FileLog implements Log {
private logEnabled = true;
constructor(private readonly logFile?: string) {
constructor(private logFile: string | undefined) {
}

isEnabled = () => {
return this.logEnabled && this.logFile !== undefined;
return typeof this.logFile === "string";
}
writeLine = (text: string) => {
if (typeof this.logFile !== "string") return;

try {
fs.appendFileSync(this.logFile!, `[${nowString()}] ${text}${sys.newLine}`); // TODO: GH#18217
fs.appendFileSync(this.logFile, `[${nowString()}] ${text}${sys.newLine}`);
}
catch (e) {
this.logEnabled = false;
this.logFile = undefined;
}
}
}
Expand Down