UNPKG

@worldapi/cli

Version:

A productivity focused CLI and terminal for WorldAPI.

17 lines (16 loc) 512 B
import fs from "fs/promises"; async function searchFile_default(query, file) { try { const fileContents = await fs.readFile(file, "utf-8"); const lines = fileContents.split("\n"); const results = lines.filter((line) => line.includes(query)); if (results.length === 0) return; console.log(`${file} ${results.length} Occurrences`); } catch (error) { console.error("[WorldAPI]: An error occurred while querying the file system."); } } export { searchFile_default as default };