Socket
Socket
Sign inDemoInstall

postcss-cli

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-cli - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

7

History.md
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 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc