Node: JSON configs are read as data, not imported (store-only apps failed under npx: needs an import attribute); test, pitfall 105
This commit is contained in:
parent
bd316723f5
commit
d3d31d6c12
4 changed files with 24 additions and 0 deletions
12
tests/config-json-node.test.ts
Normal file
12
tests/config-json-node.test.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// A storebound.config.json loads without an import attribute (Node refuses a bare JSON import; pitfall 105).
|
||||
import { expect, test } from 'bun:test';
|
||||
import { mkdtempSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { importConfigModule } from '../cli/lib/rt';
|
||||
|
||||
test('importConfigModule reads a JSON config as data', async () => {
|
||||
const f = join(mkdtempSync(join(tmpdir(), 'sb-json-')), 'storebound.config.json');
|
||||
writeFileSync(f, JSON.stringify({ app: { name: 'Demo' }, play: { packageName: 'com.example.demo' } }));
|
||||
expect((await importConfigModule(f)).default.play.packageName).toBe('com.example.demo');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue