forked from unimatrix/web
Fresh production baseline [skip ci]
This commit is contained in:
commit
0a11a18274
1 changed files with 229644 additions and 0 deletions
28
website/tests/source-syntax.test.mjs
Normal file
28
website/tests/source-syntax.test.mjs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {readdirSync} from 'node:fs';
|
||||
import {join,relative,resolve} from 'node:path';
|
||||
import {spawnSync} from 'node:child_process';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
|
||||
const website=resolve(fileURLToPath(new URL('..',import.meta.url)));
|
||||
const sourceDirs=['node','control-panel','worker','integrations','scripts','web'];
|
||||
const excludedDirectories=new Set(['node_modules','native-editor','dist','build','assets']);
|
||||
function* modules(dir){
|
||||
for(const entry of readdirSync(dir,{withFileTypes:true})){
|
||||
const full=join(dir,entry.name);
|
||||
if(entry.isDirectory()&&!excludedDirectories.has(entry.name))yield* modules(full);
|
||||
else if(entry.isFile()&&/\.(?:mjs|cjs|js)$/.test(entry.name))yield full;
|
||||
}
|
||||
}
|
||||
test('first-party website modules parse without importing runtime dependencies',()=>{
|
||||
let checked=0;
|
||||
for(const directory of sourceDirs){
|
||||
for(const file of modules(join(website,directory))){
|
||||
const result=spawnSync(process.execPath,['--check',file],{encoding:'utf8'});
|
||||
assert.equal(result.status,0,`${relative(website,file)}: ${result.stderr||result.error||'syntax error'}`);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
assert.ok(checked>0,'No source modules checked');
|
||||
});
|
||||
Loading…
Reference in a new issue

Staff