INNER CODE UNIT · TypeScript

checkSpacing

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

function checkSpacing(text: string | undefined) {
  if (typeof text === 'string') {
    const hasProperSpacing = pangu.hasProperSpacing(text);
    if (!hasProperSpacing) {
      // Print the corrected version to stderr so a failing -c is debuggable. stdout stays empty, so -c composes in a pipeline
      console.error(`Corrected: ${pangu.spaceText(text)}`);
    }
    process.exitCode = hasProperSpacing ? 0 : 1;
  } else {
    console.log(usage);
    process.exitCode = 1;
  }
}

// Every exit goes through process.exitCode rather than process.exit(), because process.exit() truncates a piped stdout at one pipe buffer and pangu now streams whole files through it
async function main() {
  // -t, -f and -c are mutually exclusive
  const givenModes = new Set(args.filter((arg) => arg in modeFlags).map((flag) => modeFlags[flag]));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…