Refine min-wrapper-count error message

Signed-off-by: Paul Merlin <paul@gradle.com>
This commit is contained in:
Paul Merlin 2020-01-10 17:59:23 +01:00
parent 9393a6ed98
commit 7c1b6a0c36
3 changed files with 7 additions and 12 deletions

View file

@ -18,10 +18,9 @@ test('validates wrapper jars', async () => {
})
test('fails if not enough wrapper jars are found', async () => {
await expect(validate.findInvalidWrapperJars(
path.resolve('.'),
3,
false,
[]
)).rejects.toThrowError('Expected at least 3 but got only 2')
await expect(
validate.findInvalidWrapperJars(path.resolve('.'), 3, false, [])
).rejects.toThrowError(
'Expected to find at least 3 Gradle Wrapper JARs but got only 2'
)
})

2
dist/index.js vendored
View file

@ -949,7 +949,7 @@ function findInvalidWrapperJars(gitRepoRoot, minWrapperCount, allowSnapshots, al
return __awaiter(this, void 0, void 0, function* () {
const wrapperJars = yield find.findWrapperJars(gitRepoRoot);
if (wrapperJars.length < minWrapperCount) {
throw new Error(`Expected at least ${minWrapperCount} but got only ${wrapperJars.length}`);
throw new Error(`Expected to find at least ${minWrapperCount} Gradle Wrapper JARs but got only ${wrapperJars.length}`);
}
if (wrapperJars.length > 0) {
const validChecksums = yield checksums.fetchValidChecksums(allowSnapshots);

View file

@ -9,13 +9,9 @@ export async function findInvalidWrapperJars(
allowChecksums: string[]
): Promise<InvalidWrapperJar[]> {
const wrapperJars = await find.findWrapperJars(gitRepoRoot)
// eslint-disable-next-line no-console
console.log(
`Expected at least ${minWrapperCount} but got only ${wrapperJars.length}`
)
if (wrapperJars.length < minWrapperCount) {
throw new Error(
`Expected at least ${minWrapperCount} but got only ${wrapperJars.length}`
`Expected to find at least ${minWrapperCount} Gradle Wrapper JARs but got only ${wrapperJars.length}`
)
}
if (wrapperJars.length > 0) {