fix(.oh-my-zsh/custom/getFirebaseProject.js): add error handling if "firebase-tools.json" was not found
This commit is contained in:
parent
191cba3ad9
commit
37d613f932
@ -1,7 +1,19 @@
|
|||||||
const json = require(`${process.env.HOME}/.config/configstore/firebase-tools.json`);
|
const { readFileSync } = require(`fs`);
|
||||||
|
|
||||||
const firebaseProjectName = json.activeProjects[process.argv[2]];
|
const folderPath = process.argv[2];
|
||||||
|
try {
|
||||||
|
const pathToFirebaseToolsJson = `${process.env.HOME}/.config/configstore/firebase-tools.json`;
|
||||||
|
const fileContent = readFileSync(pathToFirebaseToolsJson);
|
||||||
|
const firebaseToolsJson = JSON.parse(fileContent);
|
||||||
|
const firebaseProjectName = firebaseToolsJson.activeProjects[folderPath];
|
||||||
|
|
||||||
if (firebaseProjectName) {
|
if (firebaseProjectName) {
|
||||||
console.log(firebaseProjectName);
|
console.log(firebaseProjectName);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code && error.code === "ENOENT") {
|
||||||
|
console.error(`Couldn't find file "${pathToFirebaseToolsJson}". Please create it with "$ firebase use <projectName>" in your project folder.`);
|
||||||
|
} else {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user