feat(tools): setup-links 批量重建 framework junction
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { join } from 'node:path';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { makeTempMonorepo, makeGameProject, cleanup } from './helpers.mjs';
|
||||
import { setupLinks } from '../setup-links.mjs';
|
||||
import { isLink } from '../lib/junction.mjs';
|
||||
|
||||
test('setupLinks 为每个子游戏工程建立 assets/framework junction', () => {
|
||||
const mono = makeTempMonorepo();
|
||||
try {
|
||||
makeGameProject(mono.games, 'doudizhu');
|
||||
makeGameProject(mono.games, 'niuniu');
|
||||
const results = setupLinks(mono.games, mono.framework);
|
||||
assert.equal(results.length, 2);
|
||||
for (const r of results) {
|
||||
assert.equal(r.status, 'created');
|
||||
assert.ok(isLink(r.link));
|
||||
assert.equal(readFileSync(join(r.link, 'README.md'), 'utf8'), '# framework src\n');
|
||||
}
|
||||
} finally {
|
||||
cleanup(mono.root);
|
||||
}
|
||||
});
|
||||
|
||||
test('setupLinks 二次运行幂等(已存在则 exists)', () => {
|
||||
const mono = makeTempMonorepo();
|
||||
try {
|
||||
makeGameProject(mono.games, 'doudizhu');
|
||||
setupLinks(mono.games, mono.framework);
|
||||
const second = setupLinks(mono.games, mono.framework);
|
||||
assert.equal(second[0].status, 'exists');
|
||||
} finally {
|
||||
cleanup(mono.root);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user