Browse Source

Merge pull request #1239 from rollup/gh-1213

suppress warnings with --silent
gh-1187
Rich Harris 8 years ago
committed by GitHub
parent
commit
40a0ed52be
  1. 1
      bin/src/help.md
  2. 4
      bin/src/runRollup.js
  3. 5
      test/cli/silent/_config.js
  4. 5
      test/cli/silent/_expected.js
  5. 1
      test/cli/silent/foo.js
  6. 3
      test/cli/silent/main.js
  7. 14
      test/test.js

1
bin/src/help.md

@ -23,6 +23,7 @@ Basic options:
--no-indent Don't indent result
--environment <values> Settings passed to config file (see example)
--no-conflict Generate a noConflict method for UMD globals
--silent Don't print warnings
--intro Content to insert at top of bundle (inside wrapper)
--outro Content to insert at end of bundle (inside wrapper)
--banner Content to insert at top of bundle (outside wrapper)

4
bin/src/runRollup.js

@ -151,6 +151,10 @@ function execute ( options, command ) {
external = ( optionsExternal || [] ).concat( commandExternal );
}
if ( command.silent ) {
options.onwarn = () => {};
}
if ( !options.onwarn ) {
const seen = new Set();

5
test/cli/silent/_config.js

@ -0,0 +1,5 @@
module.exports = {
description: 'does not print warnings with --silent',
command: 'rollup -i main.js -f cjs --silent',
stderr: ``
};

5
test/cli/silent/_expected.js

@ -0,0 +1,5 @@
'use strict';
var foo = 42;
assert.equal( foo, 42 );

1
test/cli/silent/foo.js

@ -0,0 +1 @@
export var foo = 42;

3
test/cli/silent/main.js

@ -0,0 +1,3 @@
import { foo, bar } from './foo.js';
assert.equal( foo, 42 );

14
test/test.js

@ -58,6 +58,10 @@ function loader ( modules ) {
};
}
function deindent ( str ) {
return str.slice( 1 ).replace( /^\t+/gm, '' ).replace( /\s+$/gm, '' ).trim();
}
function compareWarnings ( actual, expected ) {
assert.deepEqual(
actual.map( warning => {
@ -72,7 +76,7 @@ function compareWarnings ( actual, expected ) {
}),
expected.map( warning => {
if ( warning.frame ) {
warning.frame = warning.frame.slice( 1 ).replace( /^\t+/gm, '' ).replace( /\s+$/gm, '' ).trim();
warning.frame = deindent( warning.frame );
}
return warning;
})
@ -90,7 +94,7 @@ function compareError ( actual, expected ) {
}
if ( expected.frame ) {
expected.frame = expected.frame.slice( 1 ).replace( /^\t+/gm, '' ).replace( /\s+$/gm, '' ).trim();
expected.frame = deindent( expected.frame );
}
assert.deepEqual( actual, expected );
@ -498,7 +502,11 @@ describe( 'rollup', function () {
}
}
if ( stderr ) console.error( stderr );
if ( 'stderr' in config ) {
assert.equal( deindent( config.stderr ), stderr.trim() );
} else if ( stderr ) {
console.error( stderr );
}
let unintendedError;

Loading…
Cancel
Save