MCPcopy
hub / github.com/zarazhangrui/follow-builders / getDigestText

Function getDigestText

scripts/deliver.js:38–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37// The digest text can come from stdin, --message flag, or --file flag
38async function getDigestText() {
39 const args = process.argv.slice(2);
40
41 // Check --message flag
42 const msgIdx = args.indexOf('--message');
43 if (msgIdx !== -1 && args[msgIdx + 1]) {
44 return args[msgIdx + 1];
45 }
46
47 // Check --file flag
48 const fileIdx = args.indexOf('--file');
49 if (fileIdx !== -1 && args[fileIdx + 1]) {
50 return await readFile(args[fileIdx + 1], 'utf-8');
51 }
52
53 // Read from stdin
54 const chunks = [];
55 for await (const chunk of process.stdin) {
56 chunks.push(chunk);
57 }
58 return Buffer.concat(chunks).toString('utf-8');
59}
60
61// -- Telegram Delivery -------------------------------------------------------
62

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected