postcss-cli
Advanced tools
Comparing version 0.3.0 to 1.0.0
53
index.js
@@ -7,3 +7,5 @@ var argv = require("yargs") | ||
'Pass plugin parameters in plugin.option notation') | ||
.demand(1, 'Please specify input file.') | ||
.example('postcss -u postcss-cachify -u autoprefixer -d build *.css', | ||
'Use multiple plugins and multiple input files') | ||
.demand(1, 'Please specify at least one input file.') | ||
.config('c') | ||
@@ -17,4 +19,5 @@ .alias('c', 'config') | ||
.describe('o', 'Output file') | ||
.demand('o', 'Please specify output file.') | ||
.requiresArg(['u', 'c', 'o']) | ||
.alias('d', 'dir') | ||
.describe('d', 'Output directory') | ||
.requiresArg(['u', 'c', 'o', 'd']) | ||
.boolean('safe') | ||
@@ -32,2 +35,14 @@ .describe('safe', 'Enable postcss safe mode.') | ||
.wrap() | ||
.check(function(argv) { | ||
if (argv._.length > 1 && !argv.dir) { | ||
throw 'Please specify --dir [output directory] for your files'; | ||
} | ||
if (argv.output && argv.dir) { | ||
throw 'Both `output file` and `output directory` provided: please use either --output or --dir option.'; | ||
} | ||
if (!argv.output && !argv.dir) { | ||
throw 'Please specify --output [output file name] or --dir [out files location]'; | ||
} | ||
return true; | ||
}) | ||
.argv; | ||
@@ -45,3 +60,3 @@ | ||
} else { | ||
plugin = plugin.postcss; | ||
plugin = plugin.postcss || plugin(); | ||
} | ||
@@ -51,19 +66,23 @@ return plugin; | ||
var fs = require('fs'); | ||
var input = argv._[0]; | ||
var output = argv.output; | ||
var css = fs.readFileSync(input, 'utf8'); | ||
var path = require('path'); | ||
var postcss = require('postcss'); | ||
var processor = postcss(plugins); | ||
var result = processor.process(css, { | ||
safe: argv.safe, | ||
from: input, | ||
to: output | ||
}); | ||
function process(processor, input, output) { | ||
var css = fs.readFileSync(input, 'utf8'); | ||
var result = processor.process(css, { | ||
safe: argv.safe, | ||
from: input, | ||
to: output | ||
}); | ||
fs.writeFileSync(output, result.css); | ||
} | ||
fs.writeFileSync(output, result.css); | ||
argv._.forEach(function(input) { | ||
var output = argv.output; | ||
if(!output) { | ||
output = path.join(argv.dir, path.basename(input)); | ||
} | ||
process(processor, input, output); | ||
}); |
{ | ||
"name": "postcss-cli", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "CLI for postcss", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
"postcss": "^4.0.6", | ||
"yargs": "pirxpilot/yargs#3.5.4-postcss-cli" | ||
"yargs": "^3.6.0" | ||
}, | ||
@@ -24,0 +24,0 @@ "devDependencies": { |
@@ -19,4 +19,9 @@ [![Build Status](https://img.shields.io/travis/code42day/postcss-cli.svg)](http://travis-ci.org/code42day/postcss-cli) | ||
Output file name - required | ||
Output file name | ||
#### `--dir|-d` | ||
Output files location. Either `--output` or `--dir` option, but not both of them, need to be specified. | ||
`--dir` needs to be used if multiple input file is provided. | ||
#### `--use|-u` | ||
@@ -75,2 +80,6 @@ | ||
Use multiple plugins and multiple input files | ||
postcss -u postcss-cachify -u autoprefixer -d build *.css | ||
## Licence | ||
@@ -77,0 +86,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
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5202
78
1
88
0
+ Addedansi-regex@2.1.1(transitive)
+ Addedcamelcase@2.1.1(transitive)
+ Addedcliui@3.2.0(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedinvert-kv@1.0.0(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedlcid@1.0.0(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedos-locale@1.4.0(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedwindow-size@0.1.4(transitive)
+ Addedwrap-ansi@2.1.0(transitive)
+ Addedy18n@3.2.2(transitive)
+ Addedyargs@3.32.0(transitive)
Updatedyargs@^3.6.0