Skip to content

Commit

Permalink
refactor: use function factory instead of class instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Aug 8, 2019
1 parent e549ed8 commit 98888e0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 55 deletions.
4 changes: 2 additions & 2 deletions src/index-rollup-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
'use strict';

const _ = require('lodash');
const LicensePlugin = require('./license-plugin.js');
const licensePlugin = require('./license-plugin.js');

module.exports = (options = {}) => {
const plugin = new LicensePlugin(options);
const plugin = licensePlugin(options);

return {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/index-rollup-stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
'use strict';

const _ = require('lodash');
const LicensePlugin = require('./license-plugin.js');
const licensePlugin = require('./license-plugin.js');

module.exports = (options = {}) => {
const plugin = new LicensePlugin(options);
const plugin = licensePlugin(options);

return {
/**
Expand Down
14 changes: 13 additions & 1 deletion src/license-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ function fixSourceMapOptions(options) {

/**
* Rollup Plugin.
* @class
*/
module.exports = class LicensePlugin {
class LicensePlugin {
/**
* Initialize plugin.
*
Expand Down Expand Up @@ -475,4 +476,15 @@ module.exports = class LicensePlugin {

return COMMENT_STYLES[style] ? generateBlockComment(text, COMMENT_STYLES[style]) : text;
}
}

/**
* Create new `rollup-plugin-license` instance with given
* options.
*
* @param {Object} options Option object.
* @return {LicensePlugin} The new instance.
*/
module.exports = function licensePlugin(options) {
return new LicensePlugin(options);
};
Loading

0 comments on commit 98888e0

Please sign in to comment.