liferay-npm-build-tools-common
Advanced tools
Comparing version 1.6.1 to 1.7.0-alpha.0e246ccd
@@ -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 |
@@ -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.6.1", | ||
"version": "1.7.0-alpha.0e246ccd", | ||
"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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
124670
49
1938
2
1