@@ -15,132 +15,9 @@ const postcss = require('postcss')
1515const postcssrc = require ( 'postcss-load-config' )
1616const reporter = require ( 'postcss-reporter/lib/formatter' ) ( )
1717
18+ const argv = require ( './lib/args' )
1819const depGraph = require ( './lib/depGraph' )
1920
20- const logo = `
21- /|\\
22- // //
23- // //
24- //___*___*___//
25- //--*---------*--//
26- /|| * * ||/
27- // ||* *|| //
28- // || * * || //
29- //_____||___*_________*___||_____//
30- `
31-
32- const version = ( ) => {
33- const cli = require ( './package.json' ) . version
34-
35- return chalk . bold . red ( `
36- /|\\
37- // //
38- // //
39- //___*___*___//
40- //--*---------*--//
41- /|| * * ||/
42- // ||* v${ cli } *|| //
43- // || * * || //
44- //_____||___*_________*___||_____//
45- ` )
46- }
47-
48- const argv = require ( 'yargs' )
49- . usage (
50- `${ chalk . bold . red ( logo ) }
51- Usage:
52-
53- $0 [input.css] [OPTIONS] [--output|-o output.css] [--watch]`
54- )
55- . option ( 'o' , {
56- alias : 'output' ,
57- desc : 'Output file' ,
58- type : 'string'
59- } )
60- . option ( 'd' , {
61- alias : 'dir' ,
62- desc : 'Output directory' ,
63- type : 'string'
64- } )
65- . option ( 'r' , {
66- alias : 'replace' ,
67- desc : 'Replace (overwrite) the input file' ,
68- type : 'boolean'
69- } )
70- . option ( 'u' , {
71- alias : 'use' ,
72- desc : 'List of postcss plugins to use' ,
73- type : 'array'
74- } )
75- . option ( 'p' , {
76- alias : 'parser' ,
77- desc : 'Custom postcss parser' ,
78- type : 'string'
79- } )
80- . option ( 't' , {
81- alias : 'stringifier' ,
82- desc : 'Custom postcss stringifier' ,
83- type : 'string'
84- } )
85- . option ( 's' , {
86- alias : 'syntax' ,
87- desc : 'Custom postcss syntax' ,
88- type : 'string'
89- } )
90- . option ( 'w' , {
91- alias : 'watch' ,
92- desc : 'Watch files for changes and recompile as needed' ,
93- type : 'boolean'
94- } )
95- . option ( 'poll' , {
96- desc :
97- 'Use polling for file watching. Can optionally pass polling interval; default 100 ms'
98- } )
99- . option ( 'x' , {
100- alias : 'ext' ,
101- desc : 'Override the output file extension' ,
102- type : 'string' ,
103- coerce ( ext ) {
104- if ( ext . indexOf ( '.' ) !== 0 ) return `.${ ext } `
105- return ext
106- }
107- } )
108- . option ( 'e' , {
109- alias : 'env' ,
110- desc : 'A shortcut for setting NODE_ENV' ,
111- type : 'string'
112- } )
113- . option ( 'b' , {
114- alias : 'base' ,
115- desc :
116- 'Mirror the directory structure relative to this path in the output directory, this only works together with --dir' ,
117- type : 'string'
118- } )
119- . option ( 'c' , {
120- alias : 'config' ,
121- desc : 'Set a custom path to look for a config file' ,
122- type : 'string'
123- } )
124- . alias ( 'm' , 'map' )
125- . describe ( 'm' , 'Create an external sourcemap' )
126- . describe ( 'no-map' , 'Disable the default inline sourcemaps' )
127- . version ( version )
128- . alias ( 'v' , 'version' )
129- . help ( 'h' )
130- . alias ( 'h' , 'help' )
131- . example ( '$0 input.css -o output.css' , 'Basic usage' )
132- . example (
133- 'cat input.css | $0 -u autoprefixer > output.css' ,
134- 'Piping input & output'
135- )
136- . epilog (
137- `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout.
138-
139- If there are multiple input files, the --dir or --replace option must be passed.
140-
141- For more details, please see https://github.com/postcss/postcss-cli`
142- ) . argv
143-
14421const dir = argv . dir
14522
14623let input = argv . _
0 commit comments