-
Notifications
You must be signed in to change notification settings - Fork 1
/
S-Lisp.js
41 lines (35 loc) · 873 Bytes
/
S-Lisp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var router=require('express').Router();
var fs=require("fs");
var path=require('path');
var resolve=function(p){
return path.join('./public/',p);
};
var circle=function(core,p,prefix) {
var files=fs.readdirSync(p);
files.forEach(function(file,i) {
var f_path=p+"/"+file;
var f_name=prefix+file;
var info = fs.statSync(f_path);
if(info.isDirectory()){
circle(core,f_path,f_name+"/");
}else{
if(file.endsWith(".lisp")){
core[f_name]=fs.readFileSync(f_path,"utf-8");
}
}
});
};
router.get("/package",function(req,res,next) {
var core={};
var dir=process.env.S_LISP||"./S-Lisp";
circle(core,dir,"lib-path/");
var p="./public/index/S-Lisp/";
circle(core,p,"index/S-Lisp/");
fs.writeFile(p+"core.js", JSON.stringify(core,"",2),function(err){
res.json({
code:0,
description:"操作成功"
});
});
});
module.exports=router;