Skip to content

Commit

Permalink
Merge pull request #1018 from chromaui/reuben/ap-4370-the-turbosnap-m…
Browse files Browse the repository at this point in the history
…anifest-tracing-logic-doesnt-work

test setting outOfSync to false
  • Loading branch information
ethriel3695 authored Jul 31, 2024
2 parents 4193a27 + 474041e commit 0ce447e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
26 changes: 19 additions & 7 deletions node-src/lib/findChangedDependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const buildDepTree = vi.mocked(buildDepTreeFromFiles);

beforeEach(() => {
getRepositoryRoot.mockResolvedValue('/root');
findFilesFromRepositoryRoot.mockImplementation((file) => Promise.resolve(file.startsWith('**') ? [] : [file]));
findFilesFromRepositoryRoot.mockImplementation((file) =>
Promise.resolve(file.startsWith('**') ? [] : [file])
);
});
afterEach(() => {
getRepositoryRoot.mockReset();
Expand Down Expand Up @@ -247,21 +249,29 @@ describe('findChangedDependencies', () => {
await expect(findChangedDependencies(context)).resolves.toEqual(['react', 'lodash']);

// Root manifest and lock files are checked
expect(buildDepTree).toHaveBeenCalledWith('/root', 'package.json', 'yarn.lock', true);
expect(buildDepTree).toHaveBeenCalledWith('/root', 'A.package.json', 'A.yarn.lock', true);
expect(buildDepTree).toHaveBeenCalledWith('/root', 'package.json', 'yarn.lock', true, false);
expect(buildDepTree).toHaveBeenCalledWith(
'/root',
'A.package.json',
'A.yarn.lock',
true,
false
);

// Subpackage manifest and lock files are checked
expect(buildDepTree).toHaveBeenCalledWith(
'/root',
'subdir/package.json',
'subdir/yarn.lock',
true
true,
false
);
expect(buildDepTree).toHaveBeenCalledWith(
'/root',
'A.subdir/package.json',
'A.subdir/yarn.lock',
true
true,
false
);
});

Expand All @@ -286,7 +296,8 @@ describe('findChangedDependencies', () => {
'/root',
'A.subdir/package.json',
'A.yarn.lock', // root lockfile
true
true,
false
);
});

Expand Down Expand Up @@ -334,7 +345,8 @@ describe('findChangedDependencies', () => {
'/root',
'A.subdir/package.json',
'A.subdir/package-lock.json',
true
true,
false
);
});
});
10 changes: 9 additions & 1 deletion node-src/lib/getDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ export const getDependencies = async (
manifestPath,
lockfilePath,
includeDev = true,
strictOutOfSync = false,
}: {
rootPath: string;
manifestPath: string;
lockfilePath: string;
includeDev?: boolean;
strictOutOfSync?: boolean;
}
) => {
try {
const headTree = await buildDepTreeFromFiles(rootPath, manifestPath, lockfilePath, includeDev);
const headTree = await buildDepTreeFromFiles(
rootPath,
manifestPath,
lockfilePath,
includeDev,
strictOutOfSync
);
return flattenDependencyTree(headTree.dependencies);
} catch (e) {
ctx.log.debug({ rootPath, manifestPath, lockfilePath }, 'Failed to get dependencies');
Expand Down

0 comments on commit 0ce447e

Please sign in to comment.