Skip to content
Snippets Groups Projects
Commit 20542e75 authored by Rhys Arkins's avatar Rhys Arkins Committed by singapore
Browse files

fix: write only updated package.json files when checking for lock files (#810)

parent 341d0fb0
No related merge requests found
...@@ -137,6 +137,9 @@ async function writeUpdatedPackageFiles(config) { ...@@ -137,6 +137,9 @@ async function writeUpdatedPackageFiles(config) {
return; return;
} }
for (const packageFile of config.updatedPackageFiles) { for (const packageFile of config.updatedPackageFiles) {
if (!packageFile.name.endsWith('package.json')) {
continue; // eslint-disable-line
}
logger.debug(`Writing ${packageFile.name}`); logger.debug(`Writing ${packageFile.name}`);
const massagedFile = JSON.parse(packageFile.contents); const massagedFile = JSON.parse(packageFile.contents);
if (massagedFile.name && !massagedFile.name.match(/^[0-9a-z-_]+$/)) { if (massagedFile.name && !massagedFile.name.match(/^[0-9a-z-_]+$/)) {
......
...@@ -226,6 +226,16 @@ describe('workers/branch/lock-files', () => { ...@@ -226,6 +226,16 @@ describe('workers/branch/lock-files', () => {
await writeUpdatedPackageFiles(config); await writeUpdatedPackageFiles(config);
expect(fs.outputFile.mock.calls).toHaveLength(0); expect(fs.outputFile.mock.calls).toHaveLength(0);
}); });
it('returns if no updated packageFiles are package.json', async () => {
config.updatedPackageFiles = [
{
name: 'Dockerfile',
contents: 'some-contents',
},
];
await writeUpdatedPackageFiles(config);
expect(fs.outputFile.mock.calls).toHaveLength(0);
});
it('writes updated packageFiles', async () => { it('writes updated packageFiles', async () => {
config.updatedPackageFiles = [ config.updatedPackageFiles = [
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment