MCPcopy Create free account
hub / github.com/bitwarden/clients / saveResultToFile

Method saveResultToFile

apps/cli/src/utils.ts:153–165  ·  view source on GitHub ↗

* Process the given data and write it to a file if possible. If the user requested RAW output and * no output name is given, the file is directly written to stdout. The resulting Response contains * an otherwise empty message then to prevent writing other information to stdout. * * If an

(data: string | Buffer, output: string, defaultFileName: string)

Source from the content-addressed store, hash-verified

151 * @return an empty [Response] if written to stdout or a [Response] with the chosen output file otherwise.
152 */
153 static async saveResultToFile(data: string | Buffer, output: string, defaultFileName: string) {
154 if ((output == null || output === "") && process.env.BW_RAW === "true") {
155 // No output is given and the user expects raw output. Since the command result is about content,
156 // we directly return the command result to stdout (and suppress further messages).
157 process.stdout.write(data);
158 return Response.success();
159 }
160
161 const filePath = await this.saveFile(data, output, defaultFileName);
162 const res = new MessageResponse("Saved " + filePath, null);
163 res.raw = filePath;
164 return Response.success(res);
165 }
166
167 static readStdin(): Promise<string> {
168 return new Promise((resolve, reject) => {

Callers 2

saveFileMethod · 0.80
saveAttachmentToFileFunction · 0.80

Calls 3

saveFileMethod · 0.95
successMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected