Skip to content

Commit

Permalink
fix(gradle-wrapper): executions files update fix (#5874)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Yakushin <driver733@gmail.com>
  • Loading branch information
driver733 committed Apr 4, 2020
1 parent d90d94f commit 9f8dcef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
32 changes: 16 additions & 16 deletions lib/manager/gradle-wrapper/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ describe('manager/gradle-wrapper/update', () => {
'gradle/wrapper/gradle-wrapper.jar',
'gradlew',
'gradlew.bat',
].map(filename =>
resolve(__dirname, `./__fixtures__/testFiles/${filename}`)
),
],
} as Git.StatusResult);

const res = await dcUpdate.updateArtifacts({
Expand All @@ -64,19 +62,21 @@ describe('manager/gradle-wrapper/update', () => {
'gradle/wrapper/gradle-wrapper.jar',
'gradlew',
'gradlew.bat',
]
.map(filename =>
resolve(__dirname, `./__fixtures__/testFiles/${filename}`)
)
.map(filePath => {
return {
artifactError: null,
file: {
name: filePath,
contents: readFileSync(filePath, 'utf8'),
},
};
})
].map(fileProjectPath => {
return {
artifactError: null,
file: {
name: fileProjectPath,
contents: readFileSync(
resolve(
__dirname,
`./__fixtures__/testFiles/${fileProjectPath}`
),
'utf8'
),
},
};
})
);

[
Expand Down
20 changes: 12 additions & 8 deletions lib/manager/gradle-wrapper/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import { gradleWrapperFileName, prepareGradleCommand } from '../gradle/index';

async function addIfUpdated(
status: Git.StatusResult,
filePath: string
projectDir: string,
fileProjectPath: string
): Promise<UpdateArtifactsResult | null> {
if (status.modified.includes(filePath)) {
if (status.modified.includes(fileProjectPath)) {
const filePath = resolve(projectDir, `./${fileProjectPath}`);
return {
artifactError: null,
file: {
name: filePath,
name: fileProjectPath,
contents: await readLocalFile(filePath),
},
};
Expand Down Expand Up @@ -66,11 +68,13 @@ export async function updateArtifacts({
const updateArtifactsResult = (
await Promise.all(
[
resolve(projectDir, './gradle/wrapper/gradle-wrapper.properties'),
resolve(projectDir, './gradle/wrapper/gradle-wrapper.jar'),
resolve(projectDir, './gradlew'),
resolve(projectDir, './gradlew.bat'),
].map(async filePath => addIfUpdated(status, filePath))
'gradle/wrapper/gradle-wrapper.properties',
'gradle/wrapper/gradle-wrapper.jar',
'gradlew',
'gradlew.bat',
].map(async fileProjectPath =>
addIfUpdated(status, projectDir, fileProjectPath)
)
)
).filter(e => e != null);
logger.debug(
Expand Down

0 comments on commit 9f8dcef

Please sign in to comment.