Skip to content

Instantly share code, notes, and snippets.

@jeiea
Created December 16, 2022 17:36
Show Gist options
  • Save jeiea/081eaacaaf9fbe433ee68e38fb045b68 to your computer and use it in GitHub Desktop.
Save jeiea/081eaacaaf9fbe433ee68e38fb045b68 to your computer and use it in GitHub Desktop.
import { expandGlob } from "https://deno.land/std@0.165.0/fs/expand_glob.ts";
main().catch(console.error);
async function main() {
const osEscaper = Deno.build.os === "windows" ? "`" : "\\";
const readPromises: Promise<string>[] = [];
for await (const path of Deno.args) {
const escaped = path.replace(/(\[|\])/g, (_, arg) => `${osEscaper}${arg}`);
for await (const entry of expandGlob(escaped, { extended: false })) {
if (entry.isFile) {
readPromises.push(Deno.readTextFile(entry.name));
}
}
}
const reads = await Promise.all(readPromises);
await Deno.writeTextFile("out.txt", reads.join("\n\n\n"));
console.log("done");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment