Skip to content
Snippets Groups Projects
Unverified Commit 394bb29f authored by Martin Herndl's avatar Martin Herndl Committed by GitHub
Browse files

fix(npm): add trailing newline when composing lockfiles (#14753)

parent 56c8616b
No related merge requests found
......@@ -13,5 +13,6 @@ exports[`modules/manager/npm/utils composeLockFile composes lockfile string out
},
\\"requires\\": true,
\\"version\\": \\"1.0.0\\"
}"
}
"
`;
......@@ -176,7 +176,8 @@ exports[`modules/manager/npm/post-update/npm performs lock file updates retainin
\\"integrity\\": \\"sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==\\"
}
}
}"
}
"
`;
exports[`modules/manager/npm/post-update/npm performs lock file updates retaining the package.json counterparts 2`] = `
......
......@@ -53,5 +53,12 @@ describe('modules/manager/npm/utils', () => {
const lockFileComposed = composeLockFile(lockFile, ' ');
expect(lockFileComposed).toMatchSnapshot();
});
it('adds trailing newline to match npms behaviour and avoid diffs', () => {
const lockFile = loadFixture('lockfile-parsing/package-lock.json');
const { detectedIndent, lockFileParsed } = parseLockFile(lockFile);
const lockFileComposed = composeLockFile(lockFileParsed, detectedIndent);
expect(lockFileComposed).toBe(lockFile);
});
});
});
......@@ -16,5 +16,5 @@ export function parseLockFile(lockFile: string): ParseLockFileResult {
}
export function composeLockFile(lockFile: LockFile, indent: string): string {
return JSON.stringify(lockFile, null, indent);
return JSON.stringify(lockFile, null, indent) + '\n';
}
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