Browse Source

apply kzc patch to prevent escape codes and emojis appearing in non-TTY stderr (#1201)

gh-786
Rich-Harris 8 years ago
parent
commit
23813bc4e7
  1. 2
      bin/src/handleError.js
  2. 7
      bin/src/runRollup.js
  3. 5
      rollup.config.cli.js

2
bin/src/handleError.js

@ -1,4 +1,4 @@
import * as chalk from 'chalk';
import chalk from 'chalk';
function stderr ( msg ) {
console.error( msg ); // eslint-disable-line no-console

7
bin/src/runRollup.js

@ -1,7 +1,7 @@
import { realpathSync } from 'fs';
import * as rollup from 'rollup';
import relative from 'require-relative';
import * as chalk from 'chalk';
import chalk from 'chalk';
import handleError from './handleError';
import relativeId from '../../src/utils/relativeId.js';
import SOURCEMAPPING_URL from './sourceMappingUrl.js';
@ -9,6 +9,9 @@ import SOURCEMAPPING_URL from './sourceMappingUrl.js';
import { install as installSourcemapSupport } from 'source-map-support';
installSourcemapSupport();
if ( !process.stderr.isTTY ) chalk.enabled = false;
const warnSymbol = process.stderr.isTTY ? `⚠️ ` : `Warning: `;
// stderr to stderr to keep `rollup main.js > bundle.js` from breaking
const stderr = console.error.bind( console ); // eslint-disable-line no-console
@ -154,7 +157,7 @@ function execute ( options, command ) {
if ( seen.has( str ) ) return;
seen.add( str );
stderr( `⚠️ ${chalk.bold( warning.message )}` );
stderr( `${warnSymbol}${chalk.bold( warning.message )}` );
if ( warning.url ) {
stderr( chalk.cyan( warning.url ) );

5
rollup.config.cli.js

@ -14,10 +14,7 @@ export default {
json(),
buble(),
commonjs({
include: 'node_modules/**',
namedExports: {
chalk: [ 'yellow', 'red', 'cyan', 'grey', 'dim', 'bold' ]
}
include: 'node_modules/**'
}),
nodeResolve({
main: true

Loading…
Cancel
Save