Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip control codes in error messages. #39

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions webpack_loader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ def filter_files(files, config):
yield F


control_sequence_re = re.compile( # See ECMA 48, 5.4 Control sequences
r'(\x1b\x5b|\x9b)' # Control Sequence Introducer
r'[\x30-\x3f]*' # Parameter Bytes
r'[\x20-\x2f]*' # Intermediate Bytes
r'[\x40-\x7e]' # Final Byte
)


def strip_control_sequences(message):
return control_sequence_re.sub('', message)


def get_bundle(bundle_name, config):
assets = get_assets(config)

Expand All @@ -80,6 +92,7 @@ def get_bundle(bundle_name, config):
elif assets.get('status') == 'error':
if 'file' not in assets:
assets['file'] = ''
assets['message'] = strip_control_sequences(assets['message'])
error = u"""
{error} in {file}
{message}
Expand Down