Skip to content

Commit b4476a7

Browse files
Add parameters in node file
1 parent 4b6f704 commit b4476a7

2 files changed

Lines changed: 39 additions & 18 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
require __DIR__ . '/../autoload.php';
3+
require __DIR__ . '/../vendor/autoload.php';
44

55
use Northys\CSSInliner\CSSInliner;
66

index.js

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
11
var request = require('request'),
22
fs = require('fs'),
3+
myHost = 'http://cssinliner.dev/',
34
myBody = null,
4-
myHost = null,
5+
myPath = null,
6+
myOutput = 'output',
57
myPrefix = '- ';
68

7-
request('http://cssinliner.dev/examples/example.php',
8-
function(err, response, body) {
9-
if(err) return console.log(err);
9+
process.argv.forEach(
10+
function(val, index, array) {
11+
if(index == 2) myPath = val;
12+
if(index == 3) myOutput = val;
13+
}
14+
);
1015

11-
myBody = body;
12-
console.log(myPrefix + 'Its works');
13-
14-
fs.writeFile('my-result.html', myBody,
15-
function(err) {
16-
if(err) {
17-
return console.log(err);
18-
}
16+
if(myPath != null){
17+
try {
18+
stats = fs.lstatSync(myPath);
19+
if (stats.isDirectory()) {
20+
21+
request(myHost + myPath + '/' + myPath + '.php',
22+
function(err, response, body) {
1923

20-
console.log(myPrefix + 'The file was saved!');
21-
}
22-
);
23-
}
24-
);
24+
if(err) console.log(err);
25+
26+
myBody = body;
27+
console.log(myPrefix + 'Its works');
28+
29+
fs.writeFile(myPath + '/' + myOutput + '.html', myBody,
30+
function(err) {
31+
if(err) {
32+
return console.log(err);
33+
}
34+
35+
console.log(myPrefix + 'The file was saved!');
36+
}
37+
);
38+
}
39+
);
40+
41+
}
42+
}catch (e){
43+
console.log(e);
44+
}
45+
}

0 commit comments

Comments
 (0)