-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
45 lines (38 loc) · 946 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var request = require('request'),
fs = require('fs'),
myHost = 'http://cssinliner.dev/',
myBody = null,
myPath = null,
myTemplatesPath = 'templates/',
myOutput = 'output',
myPrefix = '- ';
process.argv.forEach(
function(val, index, array) {
if(index == 2) myPath = val;
if(index == 3) myOutput = val;
}
);
if(myPath != null){
try {
stats = fs.lstatSync(myTemplatesPath + myPath);
if (stats.isDirectory()) {
request(myHost + myTemplatesPath + 'config.php?template=' + myPath,
function(err, response, body) {
if(err) console.log(err);
myBody = body;
console.log(myPrefix + 'Its works');
fs.writeFile(myTemplatesPath + myPath + '/' + myOutput + '.html', myBody,
function(err) {
if(err) {
return console.log(err);
}
console.log(myPrefix + 'The file was saved!');
}
);
}
);
}
}catch (e){
console.log(e);
}
}