File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ Options:
23
23
24
24
With no FILE, or when FILE is -, read standard input.
25
25
```
26
+
26
27
## Documentation
27
28
28
29
See https://github.com/jonkemp/inline-css/
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ "use strict" ;
4
+
5
+ var fs = require ( "fs" ) ;
6
+ var path = require ( "path" ) ;
7
+ var pkg = require ( "../package.json" ) ;
8
+ var inlineCss = require ( '../' ) ;
9
+
10
+ var binname = Object . keys ( pkg . bin ) [ 0 ] ;
11
+
12
+ var options = { } ;
13
+ var html = process . argv [ 2 ] ;
14
+
15
+ switch ( html ) {
16
+ case "--version" :
17
+ case "-v" :
18
+ console . log ( binname + " v" + pkg . version ) ;
19
+
20
+ break ;
21
+
22
+ case "--help" :
23
+ case "-h" :
24
+ console . log ( "Usage: " + binname + " [FILE]" ) ;
25
+ console . log ( "" ) ;
26
+ console . log ( "Description:" ) ;
27
+ console . log ( " " + pkg . description ) ;
28
+ console . log ( "" ) ;
29
+ console . log ( "Options:" ) ;
30
+ console . log ( " -h, --help Show this message." ) ;
31
+ console . log ( " -v, --version Print version information." ) ;
32
+ console . log ( "" ) ;
33
+ console . log ( "With no FILE, or when FILE is -, read standard input." ) ;
34
+
35
+ break ;
36
+
37
+ case "-" :
38
+ case undefined :
39
+ options . url = 'file://' + process . cwd ( ) + '/' ;
40
+ var stdin = process . openStdin ( ) ;
41
+ html = "" ;
42
+ stdin . setEncoding ( "utf-8" ) ;
43
+ stdin . on ( "data" , function ( chunk ) {
44
+ html += chunk ;
45
+ } ) ;
46
+ stdin . on ( "end" , function ( ) {
47
+ inlineCss ( html , options )
48
+ . then ( function ( html ) {
49
+ console . log ( html ) ;
50
+ } ) ;
51
+ } ) ;
52
+
53
+ break ;
54
+
55
+ default :
56
+ options . url = 'file://' + path . dirname ( path . resolve ( html ) ) + '/' ;
57
+ html = fs . readFileSync ( html , "utf8" ) ;
58
+ inlineCss ( html , options )
59
+ . then ( function ( html ) {
60
+ console . log ( html ) ;
61
+ } ) ;
62
+ }
63
+
Original file line number Diff line number Diff line change 37
37
" index.js" ,
38
38
" lib/"
39
39
],
40
+ "bin" : {
41
+ "inline-css" : " bin/cli.js"
42
+ },
40
43
"repository" : " jonkemp/inline-css" ,
41
44
"keywords" : [
42
45
" inline" ,
You can’t perform that action at this time.
0 commit comments