Skip to content
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

Fix extension crash when there is no root folder. #8055

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
51 changes: 30 additions & 21 deletions firebase-vscode/src/logger-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,37 @@ export function logSetup() {

// Log to file
// Only log to file if firebase.debug extension setting is true.
// Re-implement file logger call from ../../src/bin/firebase.ts to not bring
// in the entire firebase.ts file
const rootFolders = getRootFolders();
// Default to a central path, but write files to a local path if we're in a Firebase directory.
let filePath = path.join(os.homedir(), ".cache", "firebase", "logs", "vsce-debug.log");
if (fs.existsSync(path.join(rootFolders[0], "firebase.json"))) {
filePath = path.join(rootFolders[0], ".firebase", "logs", "vsce-debug.log");
}
pluginLogger.info("Logging to path", filePath);
cliLogger.add(
new transports.File({
level: "debug",
filename: filePath,
format: format.printf((info) => {
const segments = [info.message, ...(info[SPLAT] || [])].map(
tryStringify,
);
return `[${info.level}] ${stripVTControlCharacters(segments.join(" "))}`;
}),
// Re-implement file logger call from ../../src/bin/firebase.ts to not bring
// in the entire firebase.ts file
const rootFolders = getRootFolders();
// Default to a central path, but write files to a local path if we're in a Firebase directory.
let filePath = path.join(
os.homedir(),
".cache",
"firebase",
"logs",
"vsce-debug.log",
);
if (
rootFolders.length > 0 &&
fs.existsSync(path.join(rootFolders[0], "firebase.json"))
) {
filePath = path.join(rootFolders[0], ".firebase", "logs", "vsce-debug.log");
}
pluginLogger.info("Logging to path", filePath);
cliLogger.add(
new transports.File({
level: "debug",
filename: filePath,
format: format.printf((info) => {
const segments = [info.message, ...(info[SPLAT] || [])].map(
tryStringify,
);
return `[${info.level}] ${stripVTControlCharacters(segments.join(" "))}`;
}),
);
cliLogger.add(new VSCodeOutputTransport({ level: "info" }));
}),
);
cliLogger.add(new VSCodeOutputTransport({ level: "info" }));
}

/**
Expand Down
Loading