json放行

This commit is contained in:
tianmo committed 2026-09-11 14:02:48 +08:00
1 parent 99d85a9e6d
commit ba0f48c543
6 files changed
+52 -15

No files matched your search

+10
View File
@@ -35,5 +35,15 @@ try {
assert.equal(utils.discoverAssets(lateAtlas, { strictStem: true }).skeletonPath, null);
const lateSkeleton = path.join(late, 'hero.skel.bytes'); fs.writeFileSync(lateSkeleton, Buffer.from('\0' + '3.8.1\0'));
assert.equal(utils.discoverAssets(lateAtlas, { strictStem: true, refreshIndex: true }).skeletonPath, lateSkeleton);
for (const [name, json, expected] of [
['spine.json', { skeleton: { spine: '4.2.43' }, bones: [] }, 'spine'],
['empty-version.json', { skeleton: { spine: '' }, bones: [] }, 'other'],
['null-version.json', { skeleton: { spine: null }, bones: [] }, 'other'],
['fake-version.json', { skeleton: { spine: 'latest' }, bones: [] }, 'other'],
['ordinary.json', { bones: [], slots: [] }, 'other'],
]) {
const file = path.join(root, name); fs.writeFileSync(file, JSON.stringify(json));
assert.equal(utils.classifySkeletonJson(file), expected, name);
}
console.log('PASS: Eagle routing, case handling, ordinary-file exclusion, cache isolation and late-arriving skeleton');
} finally { fs.rmSync(root, { recursive: true, force: true }); }
+7
View File
@@ -24,6 +24,13 @@ const fixtures = path.resolve(process.argv[2] || path.join(__dirname, '.fixtures
const result = await generate({ src, dest: path.join(root, 'notes_thumbnail.png'), item: { name: 'notes', ext: 'txt' } });
assert.equal(result.text, text); assert.equal(result.ext, 'txt'); assert.equal(result.name, 'notes');
}
const ordinaryJson = path.join(root, 'config.json');
const ordinaryJsonDest = path.join(root, 'config_thumbnail.png');
fs.writeFileSync(ordinaryJson, JSON.stringify({ skeleton: { spine: null }, enabled: true }));
const ordinaryJsonItem = { name: 'config', ext: 'json' };
assert.equal(await generate({ src: ordinaryJson, dest: ordinaryJsonDest, item: ordinaryJsonItem }), ordinaryJsonItem);
assert.equal(fs.existsSync(ordinaryJsonDest), false, 'non-Spine JSON must leave thumbnail destination untouched');
assert.equal(ordinaryJsonItem.width, undefined); assert.equal(ordinaryJsonItem.height, undefined);
for (const [source, target] of [['spineboy-mesh.skel', 'spineboy.skel.bytes'], ['spineboy.atlas', 'spineboy.atlas.txt'], ['spineboy.png', 'spineboy.png']])
fs.copyFileSync(path.join(fixtures, source), path.join(root, target));
for (const [name, ext] of [['spineboy.atlas', 'txt'], ['spineboy.skel', 'bytes']]) {