scratchPath
uses node:path
The scratch file named file (only a name, of one in scratchDir: a .ts or .tsx file, or a file kept as
written being edited, as keptFile says), as a path.
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { HttpError } from "#codebase/tcmts/server"; import { keptFile, scratchDir } from "#codebase/tcmts/studio"; import path from "node:path"; export function scratchPath(cb: Codebase, file: string, text?: string): string { if (!/^[\w-][\w.-]*\.[A-Za-z0-9]+$/.test(file) || file.endsWith(".d.ts")) throw new HttpError(400, `${file} isn't a scratch file's name: a file beside the codebase.`); const abs = path.join(scratchDir(cb), file); if (!/\.tsx?$/.test(file) && !keptFile(cb, abs, text)) throw new HttpError( 400, `${file} isn't a scratch file: they're code (.ts, .tsx), or files kept as written being edited (Edit, on their page).`, ); return abs; }
uses
used by
- tcmts.studio.ScratchPage
- tcmts.studio.completeInScratch
- tcmts.studio.definitionInScratch
- tcmts.studio.discardScratch
- tcmts.studio.evaluateInScratch
- tcmts.studio.extractInScratch
- tcmts.studio.formatScratch
- tcmts.studio.hoverInScratch
- tcmts.studio.newScratch
- tcmts.studio.previewInScratch
- tcmts.studio.pullIntoScratch
- tcmts.studio.referencesInScratch
- tcmts.studio.renameInScratch
- tcmts.studio.runScratch
- tcmts.studio.runTestInScratch
- tcmts.studio.saveScratch
- tcmts.studio.signatureInScratch
- tcmts.studio.updateScratch