Skip to content

Commit

Permalink
Merge pull request meteor#11639 from meteor/bugfix/logging-package-chalk
Browse files Browse the repository at this point in the history
Only include chalk on server - avoid serving it to the client, even if not evaluated
  • Loading branch information
renanccastro authored Sep 21, 2021
2 parents 95535dc + 15a797c commit 2f29a34
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 67 deletions.
1 change: 0 additions & 1 deletion packages/logging/chalk

This file was deleted.

8 changes: 2 additions & 6 deletions packages/logging/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,9 @@ Log.format = (obj, options = {}) => {
sourceInfo,
stderrIndicator].join('');

const prettify = function (line, color) {
return (options.color && Meteor.isServer && color) ?
require('chalk')[color](line) : line;
};

return prettify(metaPrefix, platformColor(options.metaColor || META_COLOR)) +
prettify(message, platformColor(LEVEL_COLORS[level]));
return Formatter.prettify(metaPrefix, options.color && platformColor(options.metaColor || META_COLOR)) +
Formatter.prettify(message, options.color && platformColor(LEVEL_COLORS[level]));
};

// Turn a line of text into a loggable object.
Expand Down
4 changes: 4 additions & 0 deletions packages/logging/logging_browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Formatter = {};
Formatter.prettify = function(line, color){
return line;
}
5 changes: 5 additions & 0 deletions packages/logging/logging_server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Formatter = {};
Formatter.prettify = function(line, color){
if(!color) return line;
return require("chalk")[color](line);
}
51 changes: 0 additions & 51 deletions packages/logging/package-lock.json

This file was deleted.

7 changes: 6 additions & 1 deletion packages/logging/package.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Package.describe({
summary: 'Logging facility.',
version: '1.3.0'
version: '1.3.1'
});

Npm.depends({
'chalk': '4.1.1'
});

Npm.strip({
'es5-ext': ['test/']
Expand All @@ -16,6 +19,8 @@ Package.onUse(function (api) {
// `[email protected]` or newer.
api.use(['ejson', 'ecmascript', 'ecmascript-runtime-client']);
api.mainModule('logging.js');
api.addFiles('logging_server.js', 'server')
api.addFiles('logging_browser.js', 'client')
api.mainModule('logging_cordova.js', 'web.cordova');
});

Expand Down
8 changes: 0 additions & 8 deletions packages/logging/package.json

This file was deleted.

0 comments on commit 2f29a34

Please sign in to comment.