diff --git a/lib/config/definitions.js b/lib/config/definitions.js index d79efec676d44ec2b71fb02a74b0761b87c42f13..7a8e18877219dfb8e697733f8b36b90bffcdbaaf 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -191,10 +191,11 @@ const options = [ }, { name: 'ignorePaths', - description: 'Skip any package.json whose path matches one of these.', + description: + 'Skip any package.json whose path matches one of these. Can be string or glob pattern', type: 'list', stage: 'repository', - default: ['node_modules/'], + default: ['**/node_modules/**'], }, { name: 'dependencies', diff --git a/lib/manager/index.js b/lib/manager/index.js index eecfc92e59212c5c82fec0ad4e3e25fe84c5bfb9..091c93d46d77ab180f6de2bcb18bb3ae8a71995a 100644 --- a/lib/manager/index.js +++ b/lib/manager/index.js @@ -1,3 +1,5 @@ +const minimatch = require('minimatch'); + const docker = require('./docker/package'); const npm = require('./npm/package'); @@ -19,7 +21,10 @@ async function detectPackageFiles(input) { const config = { ...input }; const { logger } = config; const fileList = (await config.api.getFileList()).filter( - file => !config.ignorePaths.some(ignorePath => file.includes(ignorePath)) + file => + !config.ignorePaths.some( + ignorePath => file.includes(ignorePath) || minimatch(file, ignorePath) + ) ); logger.debug({ config }, 'detectPackageFiles'); config.types = {}; diff --git a/test/manager/__snapshots__/index.spec.js.snap b/test/manager/__snapshots__/index.spec.js.snap index f40065dc21f21adfd08b65904a8ec5ec9c21968e..868dd63ea6cc930186c919558877b4acd97754e5 100644 --- a/test/manager/__snapshots__/index.spec.js.snap +++ b/test/manager/__snapshots__/index.spec.js.snap @@ -22,6 +22,7 @@ Array [ exports[`manager detectPackageFiles(config) ignores node modules 1`] = ` Array [ "package.json", + "not_node_mldules/backend/package.json", ] `; diff --git a/test/manager/index.spec.js b/test/manager/index.spec.js index 87b5bb8eab662ddea49d1052e1a73805cc60ae56..f219d5605cd461c822474839e6717a719c1025fb 100644 --- a/test/manager/index.spec.js +++ b/test/manager/index.spec.js @@ -70,10 +70,11 @@ describe('manager', () => { config.api.getFileList.mockReturnValueOnce([ 'package.json', 'node_modules/backend/package.json', + 'not_node_mldules/backend/package.json', ]); const res = await manager.detectPackageFiles(config); expect(res.packageFiles).toMatchSnapshot(); - expect(res.packageFiles).toHaveLength(1); + expect(res.packageFiles).toHaveLength(2); expect(res.foundIgnoredPaths).toMatchSnapshot(); expect(res.warnings).toMatchSnapshot(); });