UNPKG

cmpstr-cli

Version:

simple CLI wrapper for the cmpstr package to normalize and compare strings directly via terminal

20 lines (19 loc) 415 B
/** * Module `readInput` for `cmpstr-cli` * * Reads input as direct string or path to file and * returns plain text. * * @author Paul Köhler (komed3) * @license MIT */ import { promises as fs } from 'fs'; export async function readInput(source) { try { await fs.access(source); return (await fs.readFile(source, 'utf-8')).trim(); } catch { return source.trim(); } }