Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
collection.skipped.add( options.cwd );
} else {
collection.matched.add( options.cwd );
}
if ( !options.packages ) {
return collection;
}
const packagesPath = path.join( options.cwd, options.packages );
const skipPackages = Array.isArray( options.skipPackages ) ? options.skipPackages : [ options.skipPackages ];
const packageJson = getPackageJson( options.cwd );
const dependencies = Object.keys( packageJson.dependencies || {} );
for ( const directory of tools.getDirectories( packagesPath ) ) {
const dependencyPath = path.join( packagesPath, directory );
try {
const dependencyName = getPackageJson( dependencyPath ).name;
if ( isValidPackage( dependencyName ) ) {
collection.matched.add( dependencyPath );
} else {
collection.skipped.add( dependencyPath );
}
} catch ( err ) {
console.warn( `Missing "package.json file in "${ dependencyPath }". Skipping.` );
}
}
return collection;
module.exports = function executeOnDependencies( options, functionToExecute ) {
const packagesAbsolutePath = path.join( options.cwd, options.packages );
const directories = tools.getDirectories( packagesAbsolutePath );
const skipPackagesList = options.skipPackages || [];
const skippedPackageNames = [];
let promise = Promise.resolve();
if ( !directories.length ) {
return promise;
}
const packageJson = getPackageJson( options.cwd );
const dependencies = Object.keys( packageJson.dependencies || {} );
for ( const directory of directories ) {
const dependencyPath = path.join( packagesAbsolutePath, directory );
const dependencyName = getPackageJson( dependencyPath ).name;
module.exports = function getSubPackagesPaths( options ) {
const packagesPath = path.join( options.cwd, options.packages );
const skipPackages = Array.isArray( options.skipPackages ) ? options.skipPackages : [ options.skipPackages ];
const pathsCollection = {
matched: new Set(),
skipped: new Set()
};
for ( const directory of tools.getDirectories( packagesPath ) ) {
const dependencyPath = path.join( packagesPath, directory );
const dependencyName = getPackageJson( dependencyPath ).name;
if ( isValidPackage( dependencyName ) ) {
pathsCollection.matched.add( dependencyPath );
} else {
pathsCollection.skipped.add( dependencyPath );
}
}
return pathsCollection;
function isValidPackage( packageName ) {
for ( const skipPackageGlob of skipPackages ) {
if ( minimatch( packageName, skipPackageGlob ) ) {
return false;