Добавить Node.js-style файловый API (глобальный объект fs)#187
Draft
evgeny-boger wants to merge 1 commit intomasterfrom
Draft
Добавить Node.js-style файловый API (глобальный объект fs)#187evgeny-boger wants to merge 1 commit intomasterfrom
evgeny-boger wants to merge 1 commit intomasterfrom
Conversation
5202579 to
fd3272d
Compare
Member
Author
CI: Build wbgo.so failureЭта ветка обновляет Codacy: 2 ложных срабатывания
|
b3aa52b to
37e6e97
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37e6e97 to
716680d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что происходит; кому и зачем нужно:
Добавляет глобальный объект
fsв движок правил wb-rules, реализующий файловый API в стиле Node.js. Это позволяет пользователям читать/писать файлы, работать с директориями, симлинками и следить за изменениями файлов прямо из скриптов правил — без внешних утилит и exec-вызовов.Типичные сценарии:
fs.watch()Что поменялось для пользователей:
Появился глобальный объект
fsсо следующими функциями:Синхронные:
fs.readFileSync(path)— чтение файла (до 10 МБ)fs.writeFileSync(path, data)— запись файлаfs.appendFileSync(path, data)— дозапись в файлfs.unlinkSync(path)— удаление файлаfs.mkdirSync(path [, {recursive}])— создание директорииfs.rmdirSync(path [, {recursive}])— удаление директорииfs.copyFileSync(src, dest)— копирование файла (потоковое, сохраняет права)fs.existsSync(path)— проверка существованияfs.statSync(path)— получение информации о файлеfs.readdirSync(path)— список файлов в директорииfs.renameSync(oldPath, newPath)— переименование/перемещениеfs.accessSync(path [, mode])— проверка прав доступаfs.realpathSync(path)— разрешение симлинковfs.readlinkSync(path)— чтение цели симлинкаАсинхронные (с callback):
fs.readFile,fs.writeFile,fs.appendFile,fs.unlink,fs.mkdir,fs.rmdir,fs.copyFile,fs.stat,fs.readdir,fs.rename,fs.access,fs.realpath,fs.readlinkНаблюдение за файлами:
fs.watch(path, callback)— возвращает объект{close()}, callback вызывается при изменении файлаКонстанты:
fs.constants.F_OK,fs.constants.R_OK,fs.constants.W_OK,fs.constants.X_OKЛимит чтения файлов — 10 МБ. Защита от удаления корневых путей (
/,.). Потоковое копирование черезio.Copy.Как проверял/а:
go test -run TestFile -vWBDEV_TARGET=bullseye-arm64 wbdev cdeb)golangci-lint run— без замечаний