Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

liferay-npm-build-tools-common

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

liferay-npm-build-tools-common - npm Package Compare versions

Comparing version 1.7.0-alpha.1158492a to 1.7.0-alpha.43ab330a

lib/__tests__/babel-ipc.test.js

30

lib/__tests__/plugin-logger.test.js

@@ -31,32 +31,2 @@ 'use strict';

});
describe('when using PlugginLogger registration', function () {
it('set and gets a registered PluginLogger correctly', function () {
var logger = new _pluginLogger2.default();
_pluginLogger2.default.set('a-key', logger);
expect(_pluginLogger2.default.get('a-key')).toBe(logger);
});
it('deletes a registered PluginLogger correctly', function () {
var logger = new _pluginLogger2.default();
_pluginLogger2.default.set('a-key', logger);
logger.info('source', 'hi');
expect(_pluginLogger2.default.get('a-key').messages.length).toBe(1);
_pluginLogger2.default.delete('a-key');
expect(_pluginLogger2.default.get('a-key').messages.length).toBe(0);
});
it('returns a dummy logger if no loggers are registered', function () {
_pluginLogger2.default.delete('a-key');
expect(_pluginLogger2.default.get('a-key')).toBeDefined();
});
});
//# sourceMappingURL=plugin-logger.test.js.map

67

lib/plugin-logger.js

@@ -48,2 +48,23 @@ 'use strict';

/**
* Log a warn message
* @param {String} source the identifier for the source of the message
* @param {Array} things the objects or strings to print
* @return {void}
*/
}, {
key: 'warn',
value: function warn(source) {
for (var _len2 = arguments.length, things = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
things[_key2 - 1] = arguments[_key2];
}
this._msgs.push({
source: source,
level: 'warn',
things: things
});
}
/**
* Log an error message

@@ -58,4 +79,4 @@ * @param {String} source the identifier for the source of the message

value: function error(source) {
for (var _len2 = arguments.length, things = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
things[_key2 - 1] = arguments[_key2];
for (var _len3 = arguments.length, things = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
things[_key3 - 1] = arguments[_key3];
}

@@ -118,44 +139,2 @@

exports.default = PluginLogger;
global._PluginLogger_ = global._PluginLogger_ || {};
/**
* Set the logger for a given key. This is used to pass loggers from the
* liferay-npm-bundler core to the Babel plugins because Babel's API doesn't
* allow any way to pass per-file custom values to plugins.
* @param {String} key the key to identify the logger (usually a file path)
* @param {PluginLogger} logger the logger
* @return {void}
*/
PluginLogger.set = function (key, logger) {
global._PluginLogger_[key] = logger;
};
/**
* Get the logger for a given key. This is used to pass loggers from the
* liferay-npm-bundler core to the Babel plugins because Babel's API doesn't
* allow any way to pass per-file custom values to plugins.
* @param {String|Object} key the key to identify the logger (usually a file path). You can also pass the state object
* passed to Babel plugins and it will be automatically dereferenced.
* @return {PluginLogger} the logger
*/
PluginLogger.get = function (key) {
if (key.file && key.file.opts && key.file.opts.filenameRelative) {
key = key.file.opts.filenameRelative;
}
return global._PluginLogger_[key] || new PluginLogger();
};
/**
* Delete the logger for a given key. This is used to pass loggers from the
* liferay-npm-bundler core to the Babel plugins because Babel's API doesn't
* allow any way to pass per-file custom values to plugins.
* @param {String} key the key to identify the logger (usually a file path)
* @return {void}
*/
PluginLogger.delete = function (key) {
delete global._PluginLogger_[key];
};
//# sourceMappingURL=plugin-logger.js.map
{
"name": "liferay-npm-build-tools-common",
"version": "1.7.0-alpha.1158492a",
"version": "1.7.0-alpha.43ab330a",
"description": "Utility library for Liferay NPM Build Tools.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -25,31 +25,1 @@ import PluginLogger from '../plugin-logger';

});
describe('when using PlugginLogger registration', () => {
it('set and gets a registered PluginLogger correctly', () => {
const logger = new PluginLogger();
PluginLogger.set('a-key', logger);
expect(PluginLogger.get('a-key')).toBe(logger);
});
it('deletes a registered PluginLogger correctly', () => {
const logger = new PluginLogger();
PluginLogger.set('a-key', logger);
logger.info('source', 'hi');
expect(PluginLogger.get('a-key').messages.length).toBe(1);
PluginLogger.delete('a-key');
expect(PluginLogger.get('a-key').messages.length).toBe(0);
});
it('returns a dummy logger if no loggers are registered', () => {
PluginLogger.delete('a-key');
expect(PluginLogger.get('a-key')).toBeDefined();
});
});

@@ -28,2 +28,16 @@ /**

/**
* Log a warn message
* @param {String} source the identifier for the source of the message
* @param {Array} things the objects or strings to print
* @return {void}
*/
warn(source, ...things) {
this._msgs.push({
source: source,
level: 'warn',
things: things,
});
}
/**
* Log an error message

@@ -74,42 +88,1 @@ * @param {String} source the identifier for the source of the message

}
global._PluginLogger_ = global._PluginLogger_ || {};
/**
* Set the logger for a given key. This is used to pass loggers from the
* liferay-npm-bundler core to the Babel plugins because Babel's API doesn't
* allow any way to pass per-file custom values to plugins.
* @param {String} key the key to identify the logger (usually a file path)
* @param {PluginLogger} logger the logger
* @return {void}
*/
PluginLogger.set = function(key, logger) {
global._PluginLogger_[key] = logger;
};
/**
* Get the logger for a given key. This is used to pass loggers from the
* liferay-npm-bundler core to the Babel plugins because Babel's API doesn't
* allow any way to pass per-file custom values to plugins.
* @param {String|Object} key the key to identify the logger (usually a file path). You can also pass the state object
* passed to Babel plugins and it will be automatically dereferenced.
* @return {PluginLogger} the logger
*/
PluginLogger.get = function(key) {
if (key.file && key.file.opts && key.file.opts.filenameRelative) {
key = key.file.opts.filenameRelative;
}
return global._PluginLogger_[key] || new PluginLogger();
};
/**
* Delete the logger for a given key. This is used to pass loggers from the
* liferay-npm-bundler core to the Babel plugins because Babel's API doesn't
* allow any way to pass per-file custom values to plugins.
* @param {String} key the key to identify the logger (usually a file path)
* @return {void}
*/
PluginLogger.delete = function(key) {
delete global._PluginLogger_[key];
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc