-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (28 loc) · 856 Bytes
/
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
var StateController = require('./svg_state_controller');
var fs = require('fs');
var path = require('path');
var readline = require("readline");
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
var fileToProcess;
rl.question("Please input the absolute or relative path of the file", function(filepath) {
try{
if(fs.existsSync(filepath)){
fileToProcess = fs.readFileSync(filepath);
}
else if(fs.existsSync(path.join(__dirname, filepath))){
fileToProcess = fs.readFileSync(path.join(__dirname, filepath));
}
} catch(e){
console.log(`Error Reading File: ${filepath}`, e);
}
if(fileToProcess){
rl.close();
}
});
rl.on("close", function() {
console.log(StateController.parseSVG(fileToProcess))
process.exit(0);
});