Init atlas-baker tool with source-dir scan and pair-detection
Creates the sporel-tool-atlas-baker Node CLI scaffold and the first phase of the bake pipeline: scan a source directory for *_diffuse.png files, pair them with optional *_height.png companions, and return alphabetically-sorted sources for deterministic re-bakes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
28
tests/scan.test.js
Normal file
28
tests/scan.test.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// tests/scan.test.js
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert');
|
||||
const path = require('node:path');
|
||||
const { scanSourceDir } = require('../src/scan');
|
||||
|
||||
const FIXTURE_DIR = path.resolve(__dirname, 'fixtures/small-fresh');
|
||||
|
||||
test('scan: 3 diffuse + 1 paired height', () => {
|
||||
const { sources, errors } = scanSourceDir(FIXTURE_DIR);
|
||||
assert.deepStrictEqual(errors, []);
|
||||
assert.strictEqual(sources.length, 3);
|
||||
// Sorted alphabetically
|
||||
assert.strictEqual(sources[0].name, 'grass');
|
||||
assert.strictEqual(sources[1].name, 'stone');
|
||||
assert.strictEqual(sources[2].name, 'water');
|
||||
// grass + stone have no height
|
||||
assert.strictEqual(sources[0].heightPath, null);
|
||||
assert.strictEqual(sources[1].heightPath, null);
|
||||
// water has height
|
||||
assert.ok(sources[2].heightPath?.endsWith('water_height.png'));
|
||||
});
|
||||
|
||||
test('scan: empty dir -> error', () => {
|
||||
const { sources, errors } = scanSourceDir(path.resolve(__dirname, 'fixtures/_empty'));
|
||||
assert.strictEqual(sources.length, 0);
|
||||
assert.ok(errors.length > 0);
|
||||
});
|
||||
Reference in New Issue
Block a user