Skip to content

Commit

Permalink
Update pkglint to use get-version-marker
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Ben-Israel committed Feb 26, 2020
1 parent cecb7e9 commit f0bf5a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
5 changes: 3 additions & 2 deletions tools/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
fileShouldNotContain,
findInnerPackages,
monoRepoRoot,
monoRepoVersion,
} from './util';

// tslint:disable-next-line: no-var-requires
Expand Down Expand Up @@ -664,7 +663,9 @@ export class MustDependonCdkByPointVersions extends ValidationRule {
public readonly name = 'dependencies/cdk-point-dependencies';

public validate(pkg: PackageJson): void {
const expectedVersion = monoRepoVersion();
// yes, ugly, but we have a bunch of references to other files in the repo
// here anyway, and it's not different than reading the root lerna.json
const expectedVersion = require('../../../scripts/get-version-marker');
const ignore = [
'@aws-cdk/cloudformation-diff',
'@aws-cdk/cfnspec',
Expand Down
13 changes: 0 additions & 13 deletions tools/pkglint/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,6 @@ export function deepSet(x: any, jsonPath: string[], value: any) {
x[jsonPath[0]] = value;
}

/**
* Find 'lerna.json' and read the global package version from there
*/
export function monoRepoVersion() {
const found = findLernaJSON();
const lernaJson = require(found);
return lernaJson.version;
}

export function findUpward(dir: string, pred: (x: string) => boolean): string | undefined {
while (true) {
if (pred(dir)) { return dir; }
Expand All @@ -167,10 +158,6 @@ export function monoRepoRoot() {
return ret;
}

function findLernaJSON() {
return path.join(monoRepoRoot(), 'lerna.json');
}

export function* findInnerPackages(dir: string): IterableIterator<string> {
for (const fname of fs.readdirSync(dir, { encoding: 'utf8' })) {
try {
Expand Down

0 comments on commit f0bf5a6

Please sign in to comment.