/
githubmirror
/
hexo
Обзор
Документация
Войти
/
githubmirror
/
hexo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lib/theme/processors/source.ts
38 строк
830 B
Mimi
Revert "refactor: backslashes on Windows (#5457)" (#5481)
21 май 2024, 06:32
Не верифицирован
21 май 2024, 06:32
5ccd66e
Код
Авторство
О чём код?
import { Pattern } from 'hexo-util'; import * as common from '../../plugins/processor/common'; import type { _File } from '../../box'; function process(file: _File) { const Asset = this.model('Asset'); const id = file.source.substring(this.base_dir.length).replace(/\\/g, '/'); const { path } = file.params; const doc = Asset.findById(id); if (file.type === 'delete') { if (doc) { return doc.remove(); } return; } return Asset.save({ _id: id, path, modified: file.type !== 'skip' }); } const pattern = new Pattern(path => { if (!path.startsWith('source/')) return false; path = path.substring(7); if (common.isHiddenFile(path) || common.isTmpFile(path) || path.includes('node_modules')) return false; return {path}; }); export const source = { pattern, process };