Skip to content

Commit

Permalink
feat: add new 'cwd' option
Browse files Browse the repository at this point in the history
Close #226
  • Loading branch information
mjeanroy committed Jul 4, 2018
1 parent 747cc2f commit 25be5f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
plugins: [
license({
sourceMap: true,
cwd: '.', // Default is process.cwd()

banner: {
file: path.join(__dirname, 'LICENSE'),
Expand Down Expand Up @@ -92,6 +93,8 @@ license({

## Changelogs

- 0.6.0
- Add `cwd` option to specify custom working directory (optional option).
- 0.5.0
- Feat: Sourcemap is now enable by default to ensure compatibility with other rollup plugins.
- Fix: Add compatibility with rollup >= 0.48.0 (the new `sourcemap` option).
Expand Down
2 changes: 1 addition & 1 deletion src/license-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LicensePlugin {
this.name = 'rollup-plugin-license';

this._options = options;
this._cwd = process.cwd();
this._cwd = options.cwd || process.cwd();
this._dependencies = {};
this._pkg = require(path.join(this._cwd, 'package.json'));
this._debug = options.debug || false;
Expand Down
10 changes: 10 additions & 0 deletions test/license-plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ describe('LicensePlugin', () => {
expect(plugin._dependencies).toEqual({});
});

it('should initialize instance with custom cwd', () => {
const cwd = path.join(__dirname, 'fixtures', 'fake-package');
const plugin = new LicensePlugin({
cwd,
});

expect(plugin._cwd).toBeDefined();
expect(plugin._cwd).toBe(cwd);
});

it('should initialize instance with sourceMap = false', () => {
const plugin = new LicensePlugin({
sourceMap: false,
Expand Down

0 comments on commit 25be5f5

Please sign in to comment.