Skip to content
Snippets Groups Projects
Unverified Commit 867c0133 authored by Tom Bowden's avatar Tom Bowden Committed by GitHub
Browse files

fix(manager/mix): Support umbrella projects (#11854)



Co-authored-by: default avatarRhys Arkins <rhys@arkins.net>
parent 78a8272c
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,7 @@ describe('manager/mix/artifacts', () => { ...@@ -84,7 +84,7 @@ describe('manager/mix/artifacts', () => {
jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce(); jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce();
setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
fs.readLocalFile.mockResolvedValueOnce('Old mix.lock'); fs.readLocalFile.mockResolvedValueOnce('Old mix.lock');
fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); fs.findLocalSiblingOrParent.mockResolvedValueOnce('mix.lock');
const execSnapshots = mockExecAll(exec); const execSnapshots = mockExecAll(exec);
fs.readLocalFile.mockResolvedValueOnce('New mix.lock'); fs.readLocalFile.mockResolvedValueOnce('New mix.lock');
expect( expect(
...@@ -102,7 +102,7 @@ describe('manager/mix/artifacts', () => { ...@@ -102,7 +102,7 @@ describe('manager/mix/artifacts', () => {
jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce(); jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce();
setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
fs.readLocalFile.mockResolvedValueOnce('Old mix.lock'); fs.readLocalFile.mockResolvedValueOnce('Old mix.lock');
fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); fs.findLocalSiblingOrParent.mockResolvedValueOnce('mix.lock');
const execSnapshots = mockExecAll(exec); const execSnapshots = mockExecAll(exec);
fs.readLocalFile.mockResolvedValueOnce('New mix.lock'); fs.readLocalFile.mockResolvedValueOnce('New mix.lock');
hostRules.find.mockReturnValueOnce({ token: 'valid_test_token' }); hostRules.find.mockReturnValueOnce({ token: 'valid_test_token' });
...@@ -141,7 +141,7 @@ describe('manager/mix/artifacts', () => { ...@@ -141,7 +141,7 @@ describe('manager/mix/artifacts', () => {
it('returns updated mix.lock in subdir', async () => { it('returns updated mix.lock in subdir', async () => {
setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
fs.getSiblingFileName.mockReturnValueOnce('subdir/mix.lock'); fs.findLocalSiblingOrParent.mockResolvedValueOnce('subdir/mix.lock');
mockExecAll(exec); mockExecAll(exec);
expect( expect(
await updateArtifacts({ await updateArtifacts({
...@@ -156,7 +156,7 @@ describe('manager/mix/artifacts', () => { ...@@ -156,7 +156,7 @@ describe('manager/mix/artifacts', () => {
it('catches write errors', async () => { it('catches write errors', async () => {
fs.readLocalFile.mockResolvedValueOnce('Current mix.lock'); fs.readLocalFile.mockResolvedValueOnce('Current mix.lock');
fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); fs.findLocalSiblingOrParent.mockResolvedValueOnce('mix.lock');
fs.writeLocalFile.mockImplementationOnce(() => { fs.writeLocalFile.mockImplementationOnce(() => {
throw new Error('not found'); throw new Error('not found');
}); });
...@@ -174,7 +174,7 @@ describe('manager/mix/artifacts', () => { ...@@ -174,7 +174,7 @@ describe('manager/mix/artifacts', () => {
it('catches exec errors', async () => { it('catches exec errors', async () => {
fs.readLocalFile.mockResolvedValueOnce('Current mix.lock'); fs.readLocalFile.mockResolvedValueOnce('Current mix.lock');
fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); fs.findLocalSiblingOrParent.mockResolvedValueOnce('mix.lock');
exec.mockImplementationOnce(() => { exec.mockImplementationOnce(() => {
throw new Error('exec-error'); throw new Error('exec-error');
}); });
......
...@@ -3,7 +3,7 @@ import { TEMPORARY_ERROR } from '../../constants/error-messages'; ...@@ -3,7 +3,7 @@ import { TEMPORARY_ERROR } from '../../constants/error-messages';
import { logger } from '../../logger'; import { logger } from '../../logger';
import { ExecOptions, exec } from '../../util/exec'; import { ExecOptions, exec } from '../../util/exec';
import { import {
getSiblingFileName, findLocalSiblingOrParent,
readLocalFile, readLocalFile,
writeLocalFile, writeLocalFile,
} from '../../util/fs'; } from '../../util/fs';
...@@ -24,7 +24,8 @@ export async function updateArtifacts({ ...@@ -24,7 +24,8 @@ export async function updateArtifacts({
return null; return null;
} }
const lockFileName = getSiblingFileName(packageFileName, 'mix.lock'); const lockFileName =
(await findLocalSiblingOrParent(packageFileName, 'mix.lock')) || 'mix.lock';
try { try {
await writeLocalFile(packageFileName, newPackageFileContent); await writeLocalFile(packageFileName, newPackageFileContent);
} catch (err) { } catch (err) {
......
import { HexDatasource } from '../../datasource/hex'; import { HexDatasource } from '../../datasource/hex';
import { logger } from '../../logger'; import { logger } from '../../logger';
import { SkipReason } from '../../types'; import { SkipReason } from '../../types';
import { getSiblingFileName, localPathExists } from '../../util/fs'; import { findLocalSiblingOrParent, localPathExists } from '../../util/fs';
import type { PackageDependency, PackageFile } from '../types'; import type { PackageDependency, PackageFile } from '../types';
const depSectionRegExp = /defp\s+deps.*do/g; const depSectionRegExp = /defp\s+deps.*do/g;
...@@ -67,7 +67,8 @@ export async function extractPackageFile( ...@@ -67,7 +67,8 @@ export async function extractPackageFile(
} }
} }
const res: PackageFile = { deps }; const res: PackageFile = { deps };
const lockFileName = getSiblingFileName(fileName, 'mix.lock'); const lockFileName =
(await findLocalSiblingOrParent(fileName, 'mix.lock')) || 'mix.lock';
// istanbul ignore if // istanbul ignore if
if (await localPathExists(lockFileName)) { if (await localPathExists(lockFileName)) {
res.lockFiles = [lockFileName]; res.lockFiles = [lockFileName];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment