Skip to content

Commit 85316b9

Browse files
authored
Merge pull request #50 from suitcss/add-throw-error-flag
Add throw error flag
2 parents eff33c5 + 9c9418f commit 85316b9

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### HEAD
22

3+
* Add `--throw-error` (`-e`) to CLI
34
* Enable `lint` option by default
45
* Add `postcss-apply`
56
* Add `postcss-color-function`

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ Usage: suitcss [<input>] [<output>]
4343
Options:
4444
4545
-h, --help output usage information
46-
-V, --version output the version number
46+
-c, --config [path] a custom PostCSS config file
47+
-i, --import-root [path] the root directory for imported css files
48+
-w, --watch watch the input file and any imports for changes
4749
-m, --minify minify output with cssnano
50+
-e, --throw-error throw an error when any warnings are found
4851
-L, --no-lint disable stylelint and postcss-bem-linter
49-
-i, --import-root [path] the root directory for imported css files
50-
-c, --config [path] a custom PostCSS config file
5152
-v, --verbose log verbose output for debugging
52-
-w, --watch watch the input file and any imports for changes
53+
-V, --version output the version number
5354
5455
Examples:
5556

bin/suitcss

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ var writeFileSync = fs.outputFileSync;
1717
*/
1818

1919
program
20-
.version(require('../package.json').version)
2120
.usage('[<input>] [<output>]')
21+
.option('-c, --config [path]', 'a custom PostCSS config file')
22+
.option('-i, --import-root [path]', 'the root directory for imported css files')
23+
.option('-w, --watch', 'watch the input file and any imports for changes')
2224
.option('-m, --minify', 'minify output with cssnano')
25+
.option('-e, --throw-error', 'throw an error when any warnings are found')
2326
.option('-L, --no-lint', 'disable stylelint and postcss-bem-linter')
24-
.option('-i, --import-root [path]', 'the root directory for imported css files')
25-
.option('-c, --config [path]', 'a custom PostCSS config file')
2627
.option('-v, --verbose', 'log verbose output for debugging')
27-
.option('-w, --watch', 'watch the input file and any imports for changes');
28+
.version(require('../package.json').version);
29+
2830

2931
/**
3032
* Examples.
@@ -113,6 +115,14 @@ function run() {
113115
lint: program.lint
114116
}, config);
115117

118+
if (program.throwError) {
119+
assign(opts, {
120+
'postcss-reporter': {
121+
throwError: true
122+
}
123+
});
124+
}
125+
116126
suitcss(css, opts).then(function(result) {
117127
if (output) {
118128
writeFileSync(output, result.css + '\n');

test/error.config.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ describe('cli', function() {
413413
});
414414
});
415415

416-
it('should output an error to stderr on conformance failure when throwError is set', function(done) {
417-
exec('node bin/suitcss -i test/fixtures -c test/error.config.json test/fixtures/import-error.css test/fixtures/cli/output.css', function(err, stdout, stderr) {
416+
it('should output an error to stderr on conformance failure when --throw-error is set', function(done) {
417+
exec('node bin/suitcss -i test/fixtures -e test/fixtures/import-error.css test/fixtures/cli/output.css', function(err, stdout, stderr) {
418418
expect(err).to.be.an('error');
419419
expect(err.code).to.equal(1);
420420
expect(stderr).to.contain('postcss-reporter: warnings or errors were found');

0 commit comments

Comments
 (0)