Skip to content

Commit f1125ba

Browse files
authored
Merge pull request #40 from watilde/release/2.6.0
Release v2.6.0
2 parents 2d9c50f + ba8bb77 commit f1125ba

File tree

5 files changed

+66
-14
lines changed

5 files changed

+66
-14
lines changed

History.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2.6.0 / 2016-08-30
2+
==================
3+
4+
* Add log option
5+
* Update postcss-import to v8.1.2 from v7.1.0
6+
* Update globby to v4.1.0 from v3.0.1
7+
* Update postcss-url to v5.1.2 from v4.0.0
8+
* Update jshint to v2.9.2 from v2.6.3
9+
* Update chokidar to v1.5.1 from v1.0.3
10+
* Update yargs to v4.7.1 from v3.32.0
11+
* Support es6 export
12+
* Allow running without plugins
13+
* Add test for --poll
14+
* Add --poll flag
15+
116
2.5.2 / 2016-04-18
217
==================
318

Makefile

Lines changed: 15 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 config-wildcard 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 no-plugin
77

88

99
DIFF = diff -q
@@ -42,6 +42,17 @@ test-watch: test/import-*.css
4242
kill `cat test/watch.pid` # FIXME: never reached on failure
4343
rm test/watch.pid
4444

45+
test-watch-poll: test/import-*.css
46+
echo '@import "import-foo.css";' > test/import-index.css
47+
./bin/postcss -c test/config-watch.js -w --poll & echo $$! > test/watch.pid
48+
sleep 1
49+
$(DIFF) test/build/watch.css test/ref/watch-1.css
50+
echo '@import "import-bar.css";' >> test/import-index.css
51+
sleep 1
52+
$(DIFF) test/build/watch.css test/ref/watch-2.css
53+
kill `cat test/watch.pid` # FIXME: never reached on failure
54+
rm test/watch.pid
55+
4556
test-local-plugins:
4657
cd test; ../bin/postcss --use a-dummy-plugin --local-plugins -o build/local-plugins in.css
4758

@@ -72,6 +83,9 @@ test/build/invalid.css: test/in-force-error.css
7283
test/build/warning.css: test/in-warning.css
7384
./bin/postcss --use ./test/dummy-plugin -o $@ $< && echo Warning is OK here....
7485

86+
test/build/no-plugin.css: test/no-plugin.css
87+
./bin/postcss ./test/no-plugin.css -o $@ && echo It works without plugins
88+
7589
test/build/config.css: test/in.css
7690
./bin/postcss -u postcss-url -c test/config.json -o $@ $<
7791
$(DIFF) $@ $(subst build,ref,$@)

index.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ var argv = require("yargs")
3030
.describe('s', 'Alternative input syntax parser')
3131
.alias('p', 'parser')
3232
.describe('p', 'Alternative CSS parser')
33+
.option('poll', {
34+
describe: 'Use polling to monitor for changes.',
35+
default: false,
36+
})
3337
.alias('t', 'stringifier')
3438
.describe('t', 'Alternative output stringifier')
39+
.alias('l', 'log')
40+
.describe('l', 'Log when file is written')
3541
.alias('w', 'watch')
3642
.describe('w', 'auto-recompile when detecting source changes')
3743
.requiresArg(['u', 'c', 'i', 'o', 'd', 's', 'p', 't'])
@@ -40,14 +46,11 @@ var argv = require("yargs")
4046
'postcss version',
4147
require('./node_modules/postcss/package.json').version
4248
].join(' ');
43-
}, 'v')
49+
})
4450
.alias('v', 'version')
4551
.help('h')
4652
.alias('h', 'help')
4753
.check(function(argv) {
48-
if (!argv.use) {
49-
throw 'Please specify at least one plugin name.';
50-
}
5154
if (argv._.length && argv.input) {
5255
throw 'Both positional arguments and --input option used for `input file`: please only use one of them.';
5356
}
@@ -100,8 +103,13 @@ var plugins = argv.use.map(function(name) {
100103
if (local) {
101104
var resolved = resolve.sync(name, {basedir: process.cwd()});
102105
plugin = require(resolved);
103-
} else {
106+
} else if (name) {
104107
plugin = require(name);
108+
} else {
109+
return null;
110+
}
111+
if (plugin.default && typeof plugin.default === 'function') {
112+
plugin = plugin.default;
105113
}
106114
if (name in argv) {
107115
plugin = plugin(argv[name]);
@@ -132,7 +140,7 @@ var path = require('path');
132140
var readFile = require('read-file-stdin');
133141
var path = require('path');
134142
var postcss = require('postcss');
135-
var processor = postcss(plugins);
143+
var processor = plugins[0] ? postcss(plugins) : postcss();
136144
var mkdirp = require('mkdirp');
137145

138146
// hook for dynamically updating the list of watched files
@@ -146,8 +154,16 @@ async.forEach(inputFiles, compile, onError);
146154
function fsWatcher(entryPoints) {
147155
var watchedFiles = entryPoints;
148156
var index = {}; // source files by entry point
157+
var opts = {};
149158

150-
var watcher = require('chokidar').watch(watchedFiles);
159+
if (argv.poll) {
160+
opts.usePolling = true;
161+
}
162+
if (typeof argv.poll === 'number') {
163+
opts.interval = argv.poll;
164+
}
165+
166+
var watcher = require('chokidar').watch(watchedFiles, opts);
151167
// recompile if any watched file is modified
152168
// TODO: only recompile relevant entry point
153169
watcher.on('change', function() {
@@ -255,6 +271,10 @@ function writeFile(name, content, fn) {
255271
fn(err);
256272
} else {
257273
fs.writeFile(name, content, fn);
274+
275+
if (argv.log) {
276+
console.log('Generated file: ' + name);
277+
}
258278
}
259279
});
260280
}

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
"author": "Damian Krzeminski <[email protected]>",
1919
"license": "MIT",
2020
"dependencies": {
21-
"globby": "^3.0.1",
21+
"globby": "^4.1.0",
2222
"mkdirp": "^0.5.1",
2323
"neo-async": "^1.0.0",
2424
"postcss": "^5.0.0",
2525
"read-file-stdin": "^0.2.0",
2626
"resolve": "^1.1.6",
27-
"yargs": "^3.32.0"
27+
"yargs": "^4.7.1"
2828
},
2929
"optionalDependencies": {
30-
"chokidar": "^1.0.3"
30+
"chokidar": "^1.5.1"
3131
},
3232
"devDependencies": {
33-
"jshint": "^2.6.3",
34-
"postcss-import": "^7.1.0",
35-
"postcss-url": "^4.0.0"
33+
"jshint": "^2.9.2",
34+
"postcss-import": "^8.1.2",
35+
"postcss-url": "^5.1.2"
3636
}
3737
}

test/no-plugin.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
margin: 0;
3+
}

0 commit comments

Comments
 (0)