/
ton-org
/
blueprint
Обзор
Документация
Войти
/
ton-org
/
blueprint
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
develop
src/compile/tact/OverwritableVirtualFileSystem.ts
32 строки
915 B
ilyar
chore: setup linting (#260)
04 июн 2025, 18:33
Не верифицирован
04 июн 2025, 18:33
d540b02
Код
Авторство
О чём код?
import { resolve, normalize, sep } from 'path'; import { existsSync, readFileSync } from 'fs'; import { VirtualFileSystem } from '@tact-lang/compiler'; export class OverwritableVirtualFileSystem implements VirtualFileSystem { root: string; overwrites: Map<string, Buffer> = new Map(); constructor(root: string) { this.root = normalize(root); if (!this.root.endsWith(sep)) { this.root += sep; } } resolve(...path: string[]): string { return normalize(resolve(this.root, ...path)); } exists(path: string): boolean { return existsSync(path); } readFile(path: string): Buffer { return this.overwrites.get(path) ?? readFileSync(path); } writeFile(path: string, content: string | Buffer): void { this.overwrites.set(path, typeof content === 'string' ? Buffer.from(content, 'utf-8') : content); } }