Skip to content

Commit

Permalink
chore: improve yarn lock error checking (#17001)
Browse files Browse the repository at this point in the history
The yarn lock checking script was always wrong: it would assume a
package was local if its version number was `0.0.0`... but this is
no longer true after running `align-version.sh`.

I don't understand why this doesn't fail on the build server, but
it definitely fails for me on my machine when trying to do a full
build "as if" I was the build server.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Oct 20, 2021
1 parent 0947b21 commit 4f392a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/check-yarn-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ async function main() {
const yarnPackages = yarnLockPackages();
const projects = await new Project(repoRoot()).getPackages();

const localPackageNames = new Set(projects.map(p => p.name));

function errorIfNotInYarnLock(package, dependencyName, dependencyVersion) {
const dependencyId = `${dependencyName}@${dependencyVersion}`;
const isLocalDependency = dependencyVersion === '0.0.0' || dependencyVersion === '^0.0.0';
const isLocalDependency = localPackageNames.has(dependencyName);
if (!isLocalDependency && !yarnPackages.has(dependencyId)) {
throw new Error(`ERROR! Dependency ${dependencyId} from ${package.name} not present in yarn.lock. Please run 'yarn install' and try again!`);
}
Expand Down

0 comments on commit 4f392a1

Please sign in to comment.