-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (49 loc) · 1.5 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// const translator = require('@parvineyvazov/json-translator');
const translator = require('./json-translator.cjs.development');
const proxy_check = require('proxy-check');
const fs = require('fs');
// const proxy = 'y0adXjeO:[email protected]:5557';
// proxy_check(proxy).then(r => {
// console.log(r); // true
// }).catch(e => {
// console.error(e); // ECONNRESET
// });
async function readProxyFile(file_path) {
const confs = {
checkerRX: /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}:(\d){1,}$/,
};
const data = await fs.promises.readFile(file_path, 'utf8');
if (!data) {
error('proxy file is empty!');
return;
}
let proxyList = data.split(/\r?\n/);
proxyList = proxyList.filter(proxy_item => confs.checkerRX.test(proxy_item));
// success(`\n---------------- Proxy Mode ----------------\n`);
global.proxyList = proxyList;
console.log(global.proxyList);
}
fs.readdir('./src', (err, files) => {
if (err) {
throw err
}
// readProxyFile('./proxy.txt');
// files object contains all files names
// log them on console
files.forEach(async file => {
console.log(file);
await translator.translateFile(
'./src/' + file,
translator.languages.Japanese,
translator.languages.English
);
fs.rename('./src/en.json', './dest/' + file, function (err) {
if (err) throw err
console.log('Done', file);
})
// fs.unlink('./src/' + file, function (err) {
// if (err) throw err
// console.log('Done', file);
// });
})
})