Skip to content

Commit

Permalink
Merge pull request #3 from schmidtk/suppress-warnings
Browse files Browse the repository at this point in the history
Suppress warning output unless --verbose flag provided.
  • Loading branch information
wallw-teal authored Jan 24, 2018
2 parents bef517d + 080ef88 commit c07e700
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion os-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@ const Promise = require('bluebird');
const path = require('path');

const dossierJarPath = path.join(path.dirname(require.resolve('js-dossier/package.json')), 'dossier.jar');
const warningRE = /WARNING/;

let args;
let verbose = false;
if (process.argv.length < 3) {
console.error('Please provide the js-dossier arguments');
process.exit(1);
} else {
args = process.argv.slice(2);

// check if verbose warning output is enabled
let verboseIndex = args.indexOf('--verbose');
if (verboseIndex > -1) {
verbose = true;

// don't pass the flag to js-dossier
args.splice(verboseIndex, 1);
}
}

const compile = function(args) {
Expand All @@ -26,7 +37,11 @@ const compile = function(args) {
});

process.stderr.on('data', function(data) {
console.log(data.toString());
data = data.toString().trim();

if (data && (verbose || !warningRE.test(data))) {
console.log(data);
}
});

process.on('error', function(err) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "genconf.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint:changed": "if git diff --name-only HEAD | grep -q 'genconf.js'; then npm run lint; fi",
"lint": "eslint genconf.js",
"lint:changed": "if git diff --name-only HEAD | grep -q '\\.js$'; then npm run lint; fi",
"lint": "eslint *.js",
"package:update": "if git diff --name-only ORIG_HEAD HEAD | grep --quiet package.json; then echo 'UPDATE: package.json changed, consider running yarn in your workspace root'; fi",
"precommit": "npm run lint:changed",
"commitmsg": "validate-commit-msg",
Expand Down

0 comments on commit c07e700

Please sign in to comment.