Skip to content

Commit

Permalink
chore(pkglint): ignore cdk.out and .cdk.staging (#8709)
Browse files Browse the repository at this point in the history
Those directories can contain `package.json` files coming for bundled
assets (integ tests) that should never be linted.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jogold authored Jun 28, 2020
1 parent 3d5d2b2 commit 991024d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions tools/pkglint/lib/packagejson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as colors from 'colors/safe';
import * as fs from 'fs-extra';
import * as path from 'path';

// do not descend into these directories when searching for `package.json` files.
export const PKGLINT_IGNORES = ['node_modules', 'cdk.out', '.cdk.staging'];

/**
* Return all package JSONs in the root directory
*/
Expand All @@ -24,8 +27,8 @@ export function findPackageJsons(root: string): PackageJson[] {
ret.push(new PackageJson(fullPath));
}

// Recurse into all dirs except node_modules
if (file !== 'node_modules' && (fs.lstatSync(fullPath)).isDirectory()) {
// Recurse into all dirs except ignored dirs
if (!PKGLINT_IGNORES.includes(file) && (fs.lstatSync(fullPath)).isDirectory()) {
recurse(fullPath);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tools/pkglint/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import { PackageJson } from "./packagejson";
import { PackageJson, PKGLINT_IGNORES } from "./packagejson";

/**
* Expect a particular JSON key to be a given value
Expand Down Expand Up @@ -168,7 +168,7 @@ export function* findInnerPackages(dir: string): IterableIterator<string> {
if (e.code !== 'ENOENT') { throw e; }
continue;
}
if (fname === 'node_modules') { continue; }
if (PKGLINT_IGNORES.includes(fname)) { continue; }

if (fs.existsSync(path.join(dir, fname, 'package.json'))) {
yield path.join(dir, fname);
Expand Down

0 comments on commit 991024d

Please sign in to comment.