|
1 |
| -/* eslint-disable */ |
| 1 | +#!/usr/bin/env node |
2 | 2 | const { readdirSync, existsSync, readFileSync } = require('fs');
|
3 | 3 |
|
4 | 4 | const getDirectories = source =>
|
@@ -53,28 +53,24 @@ let currentVersions = readPackageJsonDeps('./package.json');
|
53 | 53 | let endReturn = 0;
|
54 | 54 |
|
55 | 55 | // find all versions in the monorepo
|
56 |
| -['./packages', './demo/projects'].forEach(rootDir => { |
57 |
| - getDirectories(rootDir).forEach(subPackage => { |
58 |
| - const filePath = `${rootDir}/${subPackage}/package.json`; |
59 |
| - currentVersions = { ...currentVersions, ...readPackageJsonNameVersion(filePath) }; |
60 |
| - }); |
61 |
| -}); |
| 56 | +for (const subPackage of getDirectories('./packages')) { |
| 57 | + const filePath = `./packages/${subPackage}/package.json`; |
| 58 | + currentVersions = { ...currentVersions, ...readPackageJsonNameVersion(filePath) }; |
| 59 | +} |
62 | 60 |
|
63 | 61 | // lint all versions in packages
|
64 |
| -['./packages', './demo/projects'].forEach(rootDir => { |
65 |
| - getDirectories(rootDir).forEach(subPackage => { |
66 |
| - const filePath = `${rootDir}/${subPackage}/package.json`; |
67 |
| - const subPackageVersions = readPackageJsonDeps(filePath); |
68 |
| - const { output, newVersions } = compareVersions(currentVersions, subPackageVersions); |
69 |
| - currentVersions = { ...newVersions }; |
70 |
| - if (output) { |
71 |
| - console.log(`Version mismatches found in "${filePath}":`); |
72 |
| - console.log(output); |
73 |
| - console.log(); |
74 |
| - endReturn = 1; |
75 |
| - } |
76 |
| - }); |
77 |
| -}); |
| 62 | +for (const subPackage of getDirectories('./packages')) { |
| 63 | + const filePath = `./packages/${subPackage}/package.json`; |
| 64 | + const subPackageVersions = readPackageJsonDeps(filePath); |
| 65 | + const { output, newVersions } = compareVersions(currentVersions, subPackageVersions); |
| 66 | + currentVersions = { ...newVersions }; |
| 67 | + if (output) { |
| 68 | + console.log(`Version mismatches found in "${filePath}":`); |
| 69 | + console.log(output); |
| 70 | + console.log(); |
| 71 | + endReturn = 1; |
| 72 | + } |
| 73 | +} |
78 | 74 |
|
79 | 75 | if (endReturn === 0) {
|
80 | 76 | console.log('All versions are aligned 💪');
|
|
0 commit comments