INNER CODE UNIT · TypeScript

readStdin

vinta/pangu.js · src/node/cli.ts:42

async function readStdin() {
  return (await text(process.stdin)).replace(/\n$/, '');
}

function spaceTextPrinted(text: string | undefined) {
  if (typeof text === 'string') {
    console.log(pangu.spaceText(text));
  } else {
    console.log(usage);
    process.exitCode = 1;
  }
}

// An empty string is what -f "$EMPTY_VAR" expands to, so it counts as a missing path rather than a file to open
function spaceFilePrinted(path: string | undefined) {
  if (path) {
    // File mode only does spacing: no newline appended, the file's own EOF newlines (or lack of one) pass through untouched
    process.stdout.write(pangu.spaceFileSync(path));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…