diff --git a/lib/manager/mix/artifacts.spec.ts b/lib/manager/mix/artifacts.spec.ts index dfe078d1fa7c128274259d0ac4bc34b71f7d2dfa..99b4828e9eab20afe7346f7bd6ef411d2b835580 100644 --- a/lib/manager/mix/artifacts.spec.ts +++ b/lib/manager/mix/artifacts.spec.ts @@ -83,6 +83,7 @@ describe(getName(), () => { jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce(); setAdminConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Old mix.lock'); + fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); const execSnapshots = mockExecAll(exec); fs.readLocalFile.mockResolvedValueOnce('New mix.lock'); expect( @@ -96,8 +97,24 @@ describe(getName(), () => { expect(execSnapshots).toMatchSnapshot(); }); + it('returns updated mix.lock in subdir', async () => { + setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + fs.getSiblingFileName.mockReturnValueOnce('subdir/mix.lock'); + mockExecAll(exec); + expect( + await updateArtifacts({ + packageFileName: 'subdir/mix.exs', + updatedDeps: [{ depName: 'plug' }], + newPackageFileContent: '{}', + config, + }) + ).toBeNull(); + expect(fs.readLocalFile).toHaveBeenCalledWith('subdir/mix.lock', 'utf8'); + }); + it('catches write errors', async () => { fs.readLocalFile.mockResolvedValueOnce('Current mix.lock'); + fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); fs.writeLocalFile.mockImplementationOnce(() => { throw new Error('not found'); }); @@ -113,6 +130,7 @@ describe(getName(), () => { it('catches exec errors', async () => { fs.readLocalFile.mockResolvedValueOnce('Current mix.lock'); + fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); exec.mockImplementationOnce(() => { throw new Error('exec-error'); }); diff --git a/lib/manager/mix/artifacts.ts b/lib/manager/mix/artifacts.ts index 05c5a594de872e1046f1a8e0ce10823902a68902..8b1b68e0e7619256ef925c05a1dcec5f628258bc 100644 --- a/lib/manager/mix/artifacts.ts +++ b/lib/manager/mix/artifacts.ts @@ -2,7 +2,11 @@ import { quote } from 'shlex'; import { TEMPORARY_ERROR } from '../../constants/error-messages'; import { logger } from '../../logger'; import { ExecOptions, exec } from '../../util/exec'; -import { readLocalFile, writeLocalFile } from '../../util/fs'; +import { + getSiblingFileName, + readLocalFile, + writeLocalFile, +} from '../../util/fs'; import type { UpdateArtifact, UpdateArtifactsResult } from '../types'; export async function updateArtifacts({ @@ -16,7 +20,7 @@ export async function updateArtifacts({ return null; } - const lockFileName = 'mix.lock'; + const lockFileName = getSiblingFileName(packageFileName, 'mix.lock'); try { await writeLocalFile(packageFileName, newPackageFileContent); } catch (err) {