Created
December 16, 2022 17:36
-
-
Save jeiea/081eaacaaf9fbe433ee68e38fb045b68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expandGlob } from "https://deno.land/[email protected]/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