Files

36 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict'
// 源码文本统一入口(2026-11-07)
//
// 背景:19 个测试文件曾各自手搓 `fs.readFileSync(app.js) + 扫 src`,共 35 处。
// 每搬一个模块就要挨个改扫描范围(本次会话为加 1 个模块改了 3 处),
// 而且写法不一致(有的扫全部 ui-*.js、有的硬编码单个文件)。
//
// 本 helper 只做**语义等价**的集中化:
// appSrc() app.js 原文(等价于旧的 `fs.readFileSync(app.js)`)
// srcAll() src/*.js 全部原文(按文件名排序,结果稳定)
// appAllSrc() app.js + src/*.js(跨模块断言用)
// uiAllSrc() app.js + src/ui-*.js(只关心 UI 层的杀手级断言用)
// read(rel) 任意仓库相对路径原文
//
// 注意:本文件**不改变**任何断言的强弱。要放宽/收紧断言请明写并加注释。
const fs = require('fs')
const path = require('path')
const ROOT = path.join(__dirname, '..', '..')
function read (rel) { return fs.readFileSync(path.join(ROOT, rel), 'utf8') }
function appSrc () { return read('app.js') }
function srcAll () {
const dir = path.join(ROOT, 'src')
return fs.readdirSync(dir).filter((n) => n.endsWith('.js')).sort()
.map((n) => fs.readFileSync(path.join(dir, n), 'utf8')).join('\n')
}
function uiAllSrc () {
const dir = path.join(ROOT, 'src')
return appSrc() + '\n' + fs.readdirSync(dir).filter((n) => /^ui-.*\.js$/.test(n)).sort()
.map((n) => fs.readFileSync(path.join(dir, n), 'utf8')).join('\n')
}
function appAllSrc () { return appSrc() + '\n' + srcAll() }
module.exports = { ROOT, read, appSrc, srcAll, uiAllSrc, appAllSrc }