-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
32 lines (30 loc) · 1.44 KB
/
cli.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
#!/usr/bin/env node
var args = process.argv;
var fs = require('fs'), path = require('path')
if(args.length > 3) {
var filename = args[3]
var language = args[2]
if(language == 'html') {
if(filename.split('.').pop() == 'lop') {
var code = fs.readFileSync(path.join(path.join(args[1], '../'), filename))
fs.writeFileSync(path.join(path.join(args[1], '../'), filename.replace('.lop', '.html')), require('./htmlparser/parser.js').parse(code))
} else {
console.log('Cannot parse files that arent .lop files!')
}
} else if(language == 'markdown' || language == 'md') {
if(filename.split('.').pop() == 'lop') {
var code = fs.readFileSync(path.join(path.join(args[1], '../'), filename))
fs.writeFileSync(path.join(path.join(args[1], '../'), filename.replace('.lop', '.md')), require('./mdparser/parser.js').parse(code))
} else {
console.log('Cannot parse files that arent .lop files!')
}
}
} else if(args.length == 3) {
var filename = args[2]
if(filename.split('.').pop() == 'lop') {
var code = fs.readFileSync(path.join(path.join(args[1], '../'), filename))
fs.writeFileSync(path.join(path.join(args[1], '../'), filename.replace('.lop', '.html')), require('./htmlparser/parser.js').parse(code))
} else {
console.log('Cannot parse files that arent .lop files!')
}
}