Skip to content

Commit 141b7a3

Browse files
authored
Fix watch's glob handling, modify tests to cover this case (#97)
watch's logic used the unexpanded glob input file list. This caused errors on Windows. Now, we mutate the global input variable to contain the expanded globs. Fixes #95
1 parent b20aa08 commit 141b7a3

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ Promise.resolve()
176176
error('Must use --dir or --replace with multiple input files')
177177
}
178178

179-
return files(i)
179+
input = i
180+
181+
return files(input)
180182
})
181183
.then((results) => {
182184
if (argv.watch) {

test/watch.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'ava'
22

33
import fs from 'fs-promise'
44
import path from 'path'
5-
import { execFile } from 'child_process'
5+
import { exec, execFile } from 'child_process'
66
import chokidar from 'chokidar'
77

88
import ENV from './helpers/env.js'
@@ -44,17 +44,11 @@ test.cb('--watch works', function (t) {
4444

4545
// Start postcss-cli:
4646
watcher.on('ready', () => {
47-
cp = execFile(
48-
path.resolve('bin/postcss'),
49-
[
50-
'a.css',
51-
'-o', 'output.css',
52-
'-w',
53-
'--no-map'
54-
],
47+
// Using exec() and quoting "*.css" to test watch's glob handling:
48+
cp = exec(
49+
`${path.resolve('bin/postcss')} "*.css" -o output.css --no-map -w`,
5550
{ cwd: dir }
5651
)
57-
5852
cp.on('error', t.end)
5953
cp.on('exit', code => { if (code) t.end(code) })
6054
})

0 commit comments

Comments
 (0)