-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.json
More file actions
11 lines (11 loc) 路 2.34 KB
/
Copy pathpackage.json
File metadata and controls
11 lines (11 loc) 路 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
{
"scripts": {
"lua-check": "luac -p \"$FILE\" && luacheck \"$FILE\" --codes --ranges --no-color",
"luacheck": "luacheck \".\" --codes --ranges --no-color",
"luac-check": "node -e \"const{spawnSync}=require('child_process');const{readdirSync}=require('fs');const{join}=require('path');function walk(d){for(const e of readdirSync(d,{withFileTypes:true})){const p=join(d,e.name);if(e.isDirectory()){if(!['.git','.idea','.vscode','node_modules'].includes(e.name))walk(p);}else if(p.endsWith('.lua')){const r=spawnSync('luac',['-p',p],{stdio:['ignore','ignore','inherit']});if(r.status!==0)process.exit(r.status??1);}}}walk('.')\"",
"luajit-check": "node -e \"const{spawnSync}=require('child_process');const{readdirSync}=require('fs');const{join}=require('path');function walk(d){for(const e of readdirSync(d,{withFileTypes:true})){const p=join(d,e.name);if(e.isDirectory()){if(!['.git','.idea','.vscode','node_modules'].includes(e.name))walk(p);}else if(p.endsWith('.lua')){const r=spawnSync('luajit',['-e','assert(loadfile(arg[0])); os.exit(0)',p],{stdio:['ignore','ignore','inherit']});if(r.status!==0)process.exit(r.status??1);}}}walk('.')\"",
"luals": "node -e \"const{spawnSync}=require('child_process');const{existsSync,rmSync,mkdirSync,readFileSync}=require('fs');const{join,resolve}=require('path');let root=process.cwd();while(!existsSync(join(root,'.luarc.json'))){const up=resolve(root,'..');if(up===root)throw new Error('.luarc.json not found');root=up;}const exe=join(root,'.luals','bin','lua-language-server.exe');if(!existsSync(exe))throw new Error('LuaLS executable not found: '+exe);const log=join(root,'.luals-log');rmSync(log,{recursive:true,force:true});mkdirSync(log,{recursive:true});const r=spawnSync(exe,['--check='+join(root,'library'),'--checklevel=Error','--check_format=json','--logpath='+log,'--configpath='+join(root,'.luarc.json')],{stdio:'inherit'});if(r.status!==0)process.exit(r.status??1);const report=join(log,'check.json');if(!existsSync(report))throw new Error('LuaLS did not produce a diagnosis report: '+report);const diags=JSON.parse(readFileSync(report,'utf8'));const n=Array.isArray(diags)?diags.length:0;if(n>0){console.error('LuaLS reported '+n+' error(s).');process.exit(1);}console.log('LuaLS: no errors found.');\"",
"test": "pwsh -NoProfile -File ./.tools/test.ps1",
"test:parse": "pwsh -NoProfile -File ./.tools/test.ps1 -ParseOnly"
}
}