postcss-cli
Advanced tools
Comparing version 1.4.0 to 1.5.0
1.5.0 / 2015-07-20 | ||
================== | ||
* add watch mode (-w|--watch) in which postcss-cli observes and recompiles inputs whenever they change | ||
* update neo-async dependency to released version | ||
* update postcss-url dependency (used in tests only) | ||
1.4.0 / 2015-07-12 | ||
@@ -3,0 +10,0 @@ ================== |
83
index.js
@@ -19,2 +19,4 @@ var argv = require("yargs") | ||
.describe('d', 'Output directory') | ||
.alias('w', 'watch') | ||
.describe('w', 'auto-recompile when detecting source changes') | ||
.requiresArg(['u', 'c', 'i', 'o', 'd']) | ||
@@ -33,2 +35,5 @@ .boolean('safe') | ||
.check(function(argv) { | ||
if (!argv.use) { | ||
throw 'Please specify at least one plugin name.'; | ||
} | ||
if (argv._.length && argv.input) { | ||
@@ -44,5 +49,2 @@ throw 'Both positional arguments and --input option used for `input file`: please only use one of them.'; | ||
if (!argv.use) { | ||
throw 'Please specify at least one plugin name.'; | ||
} | ||
if (!Array.isArray(argv.use)) { | ||
@@ -52,2 +54,14 @@ argv.use = [argv.use]; | ||
var inputFiles = argv._; | ||
if (!inputFiles.length) { | ||
if (argv.input) { | ||
inputFiles = Array.isArray(argv.input) ? argv.input : [argv.input]; | ||
} else { // use stdin if nothing else is specified | ||
inputFiles = [undefined]; | ||
} | ||
} | ||
if (inputFiles.length > 1 && !argv.dir) { | ||
throw 'Please specify --dir [output directory] for your files'; | ||
} | ||
// load and configure plugin array | ||
@@ -71,9 +85,28 @@ var plugins = argv.use.map(function(name) { | ||
if (argv.watch) { | ||
var watchedFiles = inputFiles; | ||
var watcher = require('chokidar').watch(watchedFiles); | ||
watcher.on('change', function() { // TODO: support for "add", "unlink" etc.? | ||
async.forEach(inputFiles, compile, function(err) { | ||
return onError.call(this, err, true); | ||
}); | ||
}); | ||
function writeFile(name, content, fn) { | ||
if (!name) { | ||
process.stdout.write(content); | ||
return fn(); | ||
global.watchCSS = function(files) { // jshint ignore:line | ||
watcher.unwatch(watchedFiles); | ||
watcher.add(files); | ||
watchedFiles = files; | ||
}; | ||
} else { | ||
global.watchCSS = function() {}; // jshint ignore:line | ||
} | ||
async.forEach(inputFiles, compile, onError); | ||
function compile(input, fn) { | ||
var output = argv.output; | ||
if (argv.dir) { | ||
output = path.join(argv.dir, path.basename(input)); | ||
} | ||
fs.writeFile(name, content, fn); | ||
processCSS(processor, input, output, fn); | ||
} | ||
@@ -109,21 +142,3 @@ | ||
var inputs = argv._; | ||
if (!inputs.length) { | ||
if(argv.input) { | ||
inputs = Array.isArray(argv.input) ? argv.input : [argv.input]; | ||
} else { // use stdin if nothing else is specified | ||
inputs = [undefined]; | ||
} | ||
} | ||
if (inputs.length > 1 && !argv.dir) { | ||
throw 'Please specify --dir [output directory] for your files'; | ||
} | ||
async.forEach(inputs, function(input, fn) { | ||
var output = argv.output; | ||
if (argv.dir) { | ||
output = path.join(argv.dir, path.basename(input)); | ||
} | ||
processCSS(processor, input, output, fn); | ||
}, function(err) { | ||
function onError(err, keepAlive) { // XXX: avoid overloaded signature? | ||
if (err) { | ||
@@ -135,4 +150,14 @@ if (err.message && typeof err.showSourceCode === 'function') { | ||
} | ||
process.exit(1); | ||
if (!keepAlive) { | ||
process.exit(1); | ||
} | ||
} | ||
}); | ||
} | ||
function writeFile(name, content, fn) { | ||
if (!name) { | ||
process.stdout.write(content); | ||
return fn(); | ||
} | ||
fs.writeFile(name, content, fn); | ||
} |
{ | ||
"name": "postcss-cli", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "CLI for postcss", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"neo-async": "^0.6.3", | ||
"neo-async": "^1.0.0", | ||
"postcss": "^4.0.6", | ||
@@ -27,6 +27,10 @@ "read-file-stdin": "^0.2.0", | ||
}, | ||
"optionalDependencies": { | ||
"chokidar": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"jshint": "^2.6.3", | ||
"postcss-url": "^2.1.0" | ||
"postcss-import": "^6.1.1", | ||
"postcss-url": "^4.0.0" | ||
} | ||
} |
@@ -35,2 +35,20 @@ [![Build Status](https://img.shields.io/travis/code42day/postcss-cli.svg)](http://travis-ci.org/code42day/postcss-cli) | ||
#### `--watch|-w` | ||
Observe file system changes and recompile as source files change. | ||
When inlining CSS imports (e.g. with [postcss-import](https://github.com/postcss/postcss-import)), | ||
add an update handler to your JavaScript configuration file to ensure referenced modules are taken | ||
into account: | ||
```js | ||
{ | ||
"postcss-import": { | ||
onImport: function(sources) { | ||
global.watchCSS(sources); | ||
} | ||
} | ||
} | ||
``` | ||
#### `--config|-c` | ||
@@ -51,3 +69,3 @@ | ||
JS configuration can be used if functions are allowed as plugins parameters: | ||
JavaScript configuration can be used if functions are allowed as plugins parameters: | ||
@@ -60,3 +78,3 @@ ````js | ||
autoprefixer: { | ||
browsers: "> 5%" | ||
browsers: "> 5%" | ||
} | ||
@@ -63,0 +81,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9614
143
127
5
3
+ Addedanymatch@1.3.2(transitive)
+ Addedarr-diff@2.0.04.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.2.10.3.2(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedasync-each@1.0.6(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbinary-extensions@1.13.1(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbraces@1.8.52.3.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedchokidar@1.7.0(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addedexpand-brackets@0.1.52.1.4(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@0.3.22.0.4(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.44.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfsevents@1.2.13(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@2.0.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-binary-path@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedis-number@2.1.03.0.04.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmicromatch@2.3.113.1.10(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednan@2.20.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addedneo-async@1.8.2(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedreaddirp@2.2.1(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedneo-async@0.6.5(transitive)
Updatedneo-async@^1.0.0