UNPKG

@notatki/cli

Version:

A collection of tools for creating and syncing Anki notes from simple text files.

26 lines 844 B
import { glob } from "node:fs/promises"; import { join, resolve } from "node:path"; const cwd = process.cwd(); export function pathTo(...file) { return resolve(cwd, ...file); } export async function findNoteFiles(dir, exclude = ["**/.git", "**/.hg", "**/.svn", "**/node_modules"]) { const notePaths = []; const modelPaths = []; const cwd = pathTo(dir); for await (const item of glob("**/*.{note,model}", { cwd, exclude })) { const path = join(cwd, item); switch (true) { case item.endsWith(".note"): notePaths.push(path); break; case item.endsWith(".model"): modelPaths.push(path); break; } } notePaths.sort(); modelPaths.sort(); return { notePaths, modelPaths }; } //# sourceMappingURL=io.js.map