Skip to content

Commit 951e695

Browse files
committed
fix input argument
treat it in the same way as argv._ - use `input` only if no non-hyphenated options are passed, and transform it through `globby` fixes postcss#7 fixes postcss#4
1 parent cd3baca commit 951e695

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ all: clean lint test
33
lint:
44
./node_modules/.bin/jshint *.js
55

6-
TESTS = opts source-maps source-maps-file stdout stdin config config-all js-config js-config-all invalid warning
6+
TESTS = opts source-maps source-maps-file stdout stdin config config-all config-wildcard js-config js-config-all invalid warning
77

88

99
DIFF = diff -q
@@ -80,6 +80,10 @@ test/build/config-all.css: test/in.css
8080
./bin/postcss -c test/config-all.json
8181
$(DIFF) $@ $(subst build,ref,$@)
8282

83+
test/build/config-wildcard.css: test/in.css
84+
./bin/postcss -c test/config-wildcard.json
85+
$(DIFF) $@ $(subst build,ref,$@)
86+
8387
test/build/js-config.css: test/in.css
8488
./bin/postcss -u postcss-url -c test/config.js -o $@ $<
8589
$(DIFF) $@ $(subst build,ref,$@)

index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ if (argv.use.indexOf("postcss-import") !== -1) {
8383
}
8484
}
8585

86-
var inputFiles = globby.sync(argv._);
86+
var inputFiles = argv._.length ? argv._ : argv.input;
87+
inputFiles = globby.sync(inputFiles);
8788
if (!inputFiles.length) {
88-
if (argv.input) {
89-
inputFiles = Array.isArray(argv.input) ? argv.input : [argv.input];
90-
} else { // use stdin if nothing else is specified
91-
inputFiles = [undefined];
92-
}
89+
// use stdin if nothing else is specified
90+
inputFiles = [undefined];
9391
}
9492
if (inputFiles.length > 1 && !argv.dir && !argv.replace) {
9593
throw 'Please specify either --replace or --dir [output directory] for your files';

test/config-wildcard.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"use": "postcss-url",
3+
"input": "test/i?.css",
4+
"output": "test/build/config-wildcard.css",
5+
"postcss-url": {
6+
"url": "inline"
7+
}
8+
}

test/ref/config-wildcard.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body {
2+
background: url(data:image/png;base64,bm90IHJlYWxseSBhbiBpbWFnZQo=);
3+
display: flex;
4+
}

0 commit comments

Comments
 (0)