@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 327fb8d
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 00:30 UTC

Add deterministic JavaScript syntax diagnostics

davoodmehraban89 committed Sep 28, 2026 at 17:36 UTC 327fb8d11df981d0a7e3975976448b4ba4e62679
1 file changed +20
scripts/syntax-check.mjs new
+20
@@ -0,0 +1,20 @@
1 +import fs from 'node:fs';
2 +import path from 'node:path';
3 +import vm from 'node:vm';
4 +
5 +const dir=path.join(process.cwd(),'js');
6 +const files=fs.readdirSync(dir).filter(name=>name.endsWith('.js')).sort();
7 +let failed=false;
8 +for(const file of files){
9 + const source=fs.readFileSync(path.join(dir,file),'utf8');
10 + try{
11 + new vm.Script(source,{filename:'js/'+file});
12 + console.log('syntax ok:',file);
13 + }catch(error){
14 + failed=true;
15 + console.error('syntax failed:',file);
16 + console.error(error.stack||error.message);
17 + }
18 +}
19 +if(failed)process.exit(1);
20 +console.log('JavaScript syntax passed for '+files.length+' modules.');