-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadfile.js
43 lines (36 loc) · 991 Bytes
/
readfile.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
42
43
const cheerio = require('cheerio')
const fs = require("fs");
const {read_env_code} = require('./env/get_env_code')
const {read_envFunc_code} = require("./envFunc/get_envFunc_code")
function get_document(html) {
return cheerio.load(html)
}
function get_env_code() {
let code = ""
code += read_env_code()
code += fs.readFileSync('./env/globalThis.js') + ";\r\n"// 全局环境
return code;
}
function get_tools_code() {
let code = "";
code += fs.readFileSync('./tools/toolsFunc.js') + ";\r\n"
code += read_envFunc_code();
return code;
}
function get_file(dir, name) {
return fs.readFileSync(`./${dir}/${name}.js`) + ";\r\n";
}
function get_files(dir, names) {
let code = '';
for (let name of names) {
code += fs.readFileSync(`./${dir}/${name}.js`) + ";\r\n";
}
return code;
}
module.exports = {
get_document,
get_env_code,
get_tools_code,
get_file,
get_files
}