Skip to content

Commit

Permalink
fix(cli): exclude **/node_modules/**/* from copyright header searching
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Apr 15, 2020
1 parent d3ff0e2 commit 9d989bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/cli/generators/copyright/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module.exports = class CopyrightGenerator extends BaseGenerator {
answers = answers || {};
const exclude = this.options.exclude || '';
const excludePatterns = exclude.split(',').filter(p => p !== '');
excludePatterns.push('**/node_modules/**/*');

this.headerOptions = {
copyrightOwner: answers.owner || this.options.owner,
Expand Down
10 changes: 9 additions & 1 deletion packages/cli/test/fixtures/copyright/single-package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@
// License text available at https://opensource.org/licenses/MIT

// Use the same set of files (except index.js) in this folder
exports.SANDBOX_FILES = require('../index')(__dirname);
const files = require('../index')(__dirname);

// add node_modules/third-party.js
files.push({
path: 'node_modules',
file: 'third-party.js',
content: `module.exports = {}`,
});
exports.SANDBOX_FILES = files;
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ describe('lb4 copyright', function () {
`// This file is licensed under the ${spdxLicenseList['isc'].name}.`,
`// License text available at ${spdxLicenseList['isc'].url}`,
);

assertNoHeader(
['node_modules/third-party.js'],
`// Copyright ACME Inc. ${year}. All Rights Reserved.`,
'// Node module: myapp',
`// This file is licensed under the ${spdxLicenseList['isc'].name}.`,
`// License text available at ${spdxLicenseList['isc'].url}`,
);
});

it('updates copyright/license headers with options.exclude', async () => {
Expand Down Expand Up @@ -97,7 +105,7 @@ describe('lb4 copyright', function () {
);

assertNoHeader(
['lib/no-header.js'],
['lib/no-header.js', 'node_modules/third-party.js'],
`// Copyright ACME Inc. ${year}. All Rights Reserved.`,
'// Node module: myapp',
`// This file is licensed under the ${spdxLicenseList['isc'].name}.`,
Expand Down

0 comments on commit 9d989bd

Please sign in to comment.