Skip to content

Commit

Permalink
fix(gradle-wrapper): extract version from content (#5930)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Apr 9, 2020
1 parent d4f6aa4 commit 4b8af11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/manager/gradle-wrapper/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe(getName(__filename), () => {
),
'utf8'
),
config: { ...config, toVersion: '6.3' },
config: { ...config, toVersion: '6.3.0' },
});

expect(res).toEqual(
Expand Down
5 changes: 4 additions & 1 deletion lib/manager/gradle-wrapper/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { UpdateArtifact, UpdateArtifactsResult } from '../common';
import { exec, ExecOptions } from '../../util/exec';
import { readLocalFile } from '../../util/fs';
import { platform } from '../../platform';
import { VERSION_REGEX } from './search';
import { gradleWrapperFileName, prepareGradleCommand } from '../gradle/index';

async function addIfUpdated(
Expand All @@ -27,18 +28,20 @@ async function addIfUpdated(
export async function updateArtifacts({
packageFileName,
updatedDeps,
newPackageFileContent,
config,
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
try {
const projectDir = config.localDir;
logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');
const version = VERSION_REGEX.exec(newPackageFileContent).groups.version;
const gradlew = gradleWrapperFileName(config);
const gradlewPath = resolve(projectDir, `./${gradlew}`);
const cmd = await prepareGradleCommand(
gradlew,
projectDir,
await fs.stat(gradlewPath).catch(() => null),
`wrapper --gradle-version ${config.toVersion}`
`wrapper --gradle-version ${version}`
);
logger.debug(`Updating gradle wrapper: "${cmd}"`);
const execOptions: ExecOptions = {
Expand Down

0 comments on commit 4b8af11

Please sign in to comment.