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

Switch emojis to log-symbols for terminal compatibility #363

Merged
merged 3 commits into from
Dec 25, 2017
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Logger = require('./Logger');
const PackagerRegistry = require('./packagers');
const localRequire = require('./utils/localRequire');
const config = require('./utils/config');
const emoji = require('./utils/emoji');

/**
* The Bundler is the main entry point. It resolves and loads assets,
Expand Down Expand Up @@ -122,7 +123,7 @@ class Bundler extends EventEmitter {
this.errored = false;

this.logger.clear();
this.logger.status('⏳', 'Building...');
this.logger.status(emoji.progress, 'Building...');

try {
// Start worker farm, watcher, etc. if needed
Expand All @@ -144,7 +145,7 @@ class Bundler extends EventEmitter {
buildTime < 1000
? `${buildTime}ms`
: `${(buildTime / 1000).toFixed(2)}s`;
this.logger.status('✨', `Built in ${time}.`, 'green');
this.logger.status(emoji.success, `Built in ${time}.`, 'green');

return bundle;
} catch (err) {
Expand Down Expand Up @@ -304,7 +305,7 @@ class Bundler extends EventEmitter {
}

if (!this.errored) {
this.logger.status('⏳', `Building ${asset.basename}...`);
this.logger.status(emoji.progress, `Building ${asset.basename}...`);
}

// Mark the asset processed so we don't load it twice
Expand Down Expand Up @@ -461,7 +462,7 @@ class Bundler extends EventEmitter {
}

this.logger.clear();
this.logger.status('⏳', `Building ${asset.basename}...`);
this.logger.status(emoji.progress, `Building ${asset.basename}...`);

// Add the asset to the rebuild queue, and reset the timeout.
this.buildQueue.add(asset);
Expand Down
3 changes: 2 additions & 1 deletion src/Logger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const chalk = require('chalk');
const readline = require('readline');
const prettyError = require('./utils/prettyError');
const emoji = require('./utils/emoji');

class Logger {
constructor(options) {
Expand Down Expand Up @@ -51,7 +52,7 @@ class Logger {

let {message, stack} = prettyError(err, {color: this.color});

this.status('🚨', message, 'red');
this.status(emoji.error, message, 'red');
if (stack) {
this.write(stack);
}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/emoji.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const supportsEmoji = process.platform !== 'win32' || process.env.VSCODE_PID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I like the dedicated utility; should make maintenance easier!


// Fallback symbols for Windows from https://en.wikipedia.org/wiki/Code_page_437
exports.progress = supportsEmoji ? '⏳' : '∞';
exports.success = supportsEmoji ? '✨' : '√';
exports.error = supportsEmoji ? '🚨' : '×';