MCPcopy Create free account
hub / github.com/firebase/firebase-tools / cli

Function cli

src/bin/cli.ts:59–170  ·  view source on GitHub ↗
(pkg: any)

Source from the content-addressed store, hash-verified

57}
58
59export function cli(pkg: any) {
60 const updateNotifier = updateNotifierPkg({ pkg });
61
62 const args = process.argv.slice(2);
63 let cmd: CommanderStatic;
64
65 if (!process.env.DEBUG && args.includes("--debug")) {
66 process.env.DEBUG = "true";
67 }
68
69 process.env.IS_FIREBASE_CLI = "true";
70
71 const logFilename = useFileLogger();
72
73 logger.debug("-".repeat(70));
74 logger.debug("Command: ", process.argv.join(" "));
75 logger.debug("CLI Version: ", pkg.version);
76 logger.debug("Platform: ", process.platform);
77 logger.debug("Node Version: ", process.version);
78 logger.debug("Detected Agent:", detectAIAgent());
79 logger.debug("Time: ", new Date().toString());
80 if (utils.envOverrides.length) {
81 logger.debug("Env Overrides:", utils.envOverrides.join(", "));
82 }
83 logger.debug("-".repeat(70));
84 logger.debug();
85
86 fetchMOTD();
87
88 process.on("exit", (code) => {
89 code = typeof process.exitCode === "number" ? process.exitCode : code;
90 if (!process.env.DEBUG && code < 2 && fsutils.fileExistsSync(logFilename)) {
91 fs.unlinkSync(logFilename);
92 }
93
94 if (code > 0 && process.stdout.isTTY) {
95 const lastError = configstore.get("lastError") || 0;
96 const timestamp = Date.now();
97 if (lastError > timestamp - 120000) {
98 let help;
99 if (code === 1 && cmd) {
100 help = "Having trouble? Try " + clc.bold("firebase [command] --help");
101 } else {
102 help = "Having trouble? Try again or contact support with contents of firebase-debug.log";
103 }
104
105 if (cmd) {
106 console.log();
107 console.log(help);
108 }
109 }
110 configstore.set("lastError", timestamp);
111 } else {
112 configstore.delete("lastError");
113 }
114
115 // Notify about updates right before process exit.
116 try {

Callers 1

firebase.tsFile · 0.85

Calls 14

useFileLoggerFunction · 0.90
detectAIAgentFunction · 0.90
fetchMOTDFunction · 0.90
markedFunction · 0.90
errorOutFunction · 0.90
loadAllCommandsFunction · 0.85
onMethod · 0.80
helpMethod · 0.80
parseMethod · 0.80
toStringMethod · 0.65
getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected