From 59e6621d1ab502e023eecce2b77f27e64a153af4 Mon Sep 17 00:00:00 2001 From: Benjamin Haines Date: Mon, 4 Apr 2016 13:53:53 +1200 Subject: [PATCH 01/12] Add --poll flag Use polling to monitor for changes. Omitting the interval will default to 100ms. This option is useful if you're watching an NFS volume. --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 20f862a..34a1b72 100644 --- a/index.js +++ b/index.js @@ -30,6 +30,10 @@ var argv = require("yargs") .describe('s', 'Alternative input syntax parser') .alias('p', 'parser') .describe('p', 'Alternative CSS parser') + .option('poll', { + describe: 'Use polling to monitor for changes.', + default: false, + }) .alias('t', 'stringifier') .describe('t', 'Alternative output stringifier') .alias('w', 'watch') @@ -146,8 +150,16 @@ async.forEach(inputFiles, compile, onError); function fsWatcher(entryPoints) { var watchedFiles = entryPoints; var index = {}; // source files by entry point + var opts = {}; + + if (argv.poll) { + opts.usePolling = true; + } + if (typeof argv.poll === 'number') { + opts.interval = argv.poll; + } - var watcher = require('chokidar').watch(watchedFiles); + var watcher = require('chokidar').watch(watchedFiles, opts); // recompile if any watched file is modified // TODO: only recompile relevant entry point watcher.on('change', function() { From 9aaa6522e2837a96ddb5de2be302edec2d5998ac Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 20 Aug 2016 11:44:04 -0400 Subject: [PATCH 02/12] Add test for --poll --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile b/Makefile index aaa3d55..d9b9998 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,17 @@ test-watch: test/import-*.css kill `cat test/watch.pid` # FIXME: never reached on failure rm test/watch.pid +test-watch-poll: test/import-*.css + echo '@import "import-foo.css";' > test/import-index.css + ./bin/postcss -c test/config-watch.js -w --poll & echo $$! > test/watch.pid + sleep 1 + $(DIFF) test/build/watch.css test/ref/watch-1.css + echo '@import "import-bar.css";' >> test/import-index.css + sleep 1 + $(DIFF) test/build/watch.css test/ref/watch-2.css + kill `cat test/watch.pid` # FIXME: never reached on failure + rm test/watch.pid + test-local-plugins: cd test; ../bin/postcss --use a-dummy-plugin --local-plugins -o build/local-plugins in.css From a7579a3a9cb743815fd8c71067bff80bfcd27e13 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 11 Aug 2016 20:06:52 +0200 Subject: [PATCH 03/12] Allow running without plugins --- Makefile | 5 ++++- index.js | 9 ++++----- test/no-plugin.css | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 test/no-plugin.css diff --git a/Makefile b/Makefile index d9b9998..b3cb260 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ all: clean lint test lint: ./node_modules/.bin/jshint *.js -TESTS = opts source-maps source-maps-file stdout stdin config config-all config-wildcard js-config js-config-all invalid warning +TESTS = opts source-maps source-maps-file stdout stdin config config-all config-wildcard js-config js-config-all invalid warning no-plugin DIFF = diff -q @@ -83,6 +83,9 @@ test/build/invalid.css: test/in-force-error.css test/build/warning.css: test/in-warning.css ./bin/postcss --use ./test/dummy-plugin -o $@ $< && echo Warning is OK here.... +test/build/no-plugin.css: test/no-plugin.css + ./bin/postcss ./test/no-plugin.css -o $@ && echo It works without plugins + test/build/config.css: test/in.css ./bin/postcss -u postcss-url -c test/config.json -o $@ $< $(DIFF) $@ $(subst build,ref,$@) diff --git a/index.js b/index.js index 34a1b72..7d041b3 100644 --- a/index.js +++ b/index.js @@ -49,9 +49,6 @@ var argv = require("yargs") .help('h') .alias('h', 'help') .check(function(argv) { - if (!argv.use) { - throw 'Please specify at least one plugin name.'; - } if (argv._.length && argv.input) { throw 'Both positional arguments and --input option used for `input file`: please only use one of them.'; } @@ -104,8 +101,10 @@ var plugins = argv.use.map(function(name) { if (local) { var resolved = resolve.sync(name, {basedir: process.cwd()}); plugin = require(resolved); - } else { + } else if (name) { plugin = require(name); + } else { + return null; } if (name in argv) { plugin = plugin(argv[name]); @@ -136,7 +135,7 @@ var path = require('path'); var readFile = require('read-file-stdin'); var path = require('path'); var postcss = require('postcss'); -var processor = postcss(plugins); +var processor = plugins[0] ? postcss(plugins) : postcss(); var mkdirp = require('mkdirp'); // hook for dynamically updating the list of watched files diff --git a/test/no-plugin.css b/test/no-plugin.css new file mode 100644 index 0000000..293d3b1 --- /dev/null +++ b/test/no-plugin.css @@ -0,0 +1,3 @@ +body { + margin: 0; +} From a5e48ae7b5434772af4dda19081a7d4d3b73804f Mon Sep 17 00:00:00 2001 From: Yinyga Zhang Date: Thu, 11 Aug 2016 18:34:35 +0800 Subject: [PATCH 04/12] Support es6 export --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 7d041b3..0ede736 100644 --- a/index.js +++ b/index.js @@ -106,6 +106,9 @@ var plugins = argv.use.map(function(name) { } else { return null; } + if (plugin.default && typeof plugin.default === 'function') { + plugin = plugin.default; + } if (name in argv) { plugin = plugin(argv[name]); } else { From 1d279a320263a4c874ca80622187b93dd9171747 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 26 May 2016 23:23:24 +0200 Subject: [PATCH 05/12] Update yargs to v4.7.1 from v3.32.0 --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0ede736..0a9e862 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,7 @@ var argv = require("yargs") 'postcss version', require('./node_modules/postcss/package.json').version ].join(' '); - }, 'v') + }) .alias('v', 'version') .help('h') .alias('h', 'help') diff --git a/package.json b/package.json index 70a68eb..d875096 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "postcss": "^5.0.0", "read-file-stdin": "^0.2.0", "resolve": "^1.1.6", - "yargs": "^3.32.0" + "yargs": "^4.7.1" }, "optionalDependencies": { "chokidar": "^1.0.3" From b3973b3a8115d5d29ac1aea74b4eadfef019aa72 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 26 May 2016 23:24:57 +0200 Subject: [PATCH 06/12] Update chokidar to v1.5.1 from v1.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d875096..5e9a3de 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "yargs": "^4.7.1" }, "optionalDependencies": { - "chokidar": "^1.0.3" + "chokidar": "^1.5.1" }, "devDependencies": { "jshint": "^2.6.3", From 785ffbb6f3b1b0c6dcfab456f93bf7f93979e78a Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 26 May 2016 23:26:55 +0200 Subject: [PATCH 07/12] Update jshint to v2.9.2 from v2.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e9a3de..39de8be 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "chokidar": "^1.5.1" }, "devDependencies": { - "jshint": "^2.6.3", + "jshint": "^2.9.2", "postcss-import": "^7.1.0", "postcss-url": "^4.0.0" } From b4f727b236f0f985d469c4c37e7573ab6d70c606 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 26 May 2016 23:30:44 +0200 Subject: [PATCH 08/12] Update postcss-url to v5.1.2 from v4.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 39de8be..9bb04e8 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,6 @@ "devDependencies": { "jshint": "^2.9.2", "postcss-import": "^7.1.0", - "postcss-url": "^4.0.0" + "postcss-url": "^5.1.2" } } From a6a7d78527c8b9688b3823d7d69930e817d45311 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 26 May 2016 23:32:07 +0200 Subject: [PATCH 09/12] Update globby to v4.1.0 from v3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bb04e8..61358d0 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "author": "Damian Krzeminski ", "license": "MIT", "dependencies": { - "globby": "^3.0.1", + "globby": "^4.1.0", "mkdirp": "^0.5.1", "neo-async": "^1.0.0", "postcss": "^5.0.0", From 43c6d0e114979869f195c8a362b95fc57e84ad5f Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 26 May 2016 23:33:19 +0200 Subject: [PATCH 10/12] Update postcss-import to v8.1.2 from v7.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61358d0..e951375 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "jshint": "^2.9.2", - "postcss-import": "^7.1.0", + "postcss-import": "^8.1.2", "postcss-url": "^5.1.2" } } From 90ad9df2d34737d2663f9489e79d6a7f6d1be825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Sch=C3=B6nwald?= Date: Tue, 3 May 2016 11:53:02 +0200 Subject: [PATCH 11/12] Add log option --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 0a9e862..83f954a 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,8 @@ var argv = require("yargs") }) .alias('t', 'stringifier') .describe('t', 'Alternative output stringifier') + .alias('l', 'log') + .describe('l', 'Log when file is written') .alias('w', 'watch') .describe('w', 'auto-recompile when detecting source changes') .requiresArg(['u', 'c', 'i', 'o', 'd', 's', 'p', 't']) @@ -269,6 +271,10 @@ function writeFile(name, content, fn) { fn(err); } else { fs.writeFile(name, content, fn); + + if (argv.log) { + console.log('Generated file: ' + name); + } } }); } From ba8bb7712e6df8c2151f6a3a23d9fd6be9c8ec2c Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Tue, 30 Aug 2016 01:27:04 +0200 Subject: [PATCH 12/12] git changelog 2.6.0 --- History.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/History.md b/History.md index c60defb..19106f5 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,18 @@ +2.6.0 / 2016-08-30 +================== + + * Add log option + * Update postcss-import to v8.1.2 from v7.1.0 + * Update globby to v4.1.0 from v3.0.1 + * Update postcss-url to v5.1.2 from v4.0.0 + * Update jshint to v2.9.2 from v2.6.3 + * Update chokidar to v1.5.1 from v1.0.3 + * Update yargs to v4.7.1 from v3.32.0 + * Support es6 export + * Allow running without plugins + * Add test for --poll + * Add --poll flag + 2.5.2 / 2016-04-18 ==================