-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewPortScript.js
More file actions
65 lines (60 loc) · 1.64 KB
/
newPortScript.js
File metadata and controls
65 lines (60 loc) · 1.64 KB
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
58
59
60
61
62
63
64
65
let archive = process.argv[2]
let option = process.argv[3]
let saveFile = process.argv[4]
var fs = require('fs');
fs.readFile(archive, 'utf-8', function(err, data){
let allComm = [
['paraCada','forEach'],
['para','for'],
['permita','let'],
['variavel','var'],
['se','if'],
['doContrario','else'],
['definaTempoFinal','setTimeout'],
['constante','const'],
['imprima','console.log'],
['limpe','console.clear'],
['verdadeiro','true'],
['falso','false'],
['enquanto','while'],
['faca','do'],
['funcao','function'],
['troque','switch'],
['caso','case'],
['saia','break'],
['predefina','default'],
['retorne','return'],
['fragmente','substring'],
['avalie','eval '],
['tente','try'],
['pegue','catch'],
['aguarde','await '],
['nova','new '],
['assincrona','async '],
['Promessa','Promise ']
]
let commands = ''
let result = ''
try{
commands = data.split(/\n/)
commands.forEach(function(command){
allComm.forEach(function(repl){
//command = command.replaceAll(repl[0],repl[1])
while(command.indexOf(repl[0]) > -1){
command = command.replace(repl[0],repl[1])
}
})
result = result + command + '\n'
})
if (option === '-code'){
console.log(result)
}
if (option === '-save'){
saveFile = saveFile + '.js'
fs.writeFileSync(saveFile, result)
}
eval(result);
}catch(e){
console.log("Erro: " + e)
}
})