fix: use existing lock files when rebasing

Check if a lock file already exists in the current *branch* and if so then use it as the base for generating the new lock file and not the master one. Ensures that simple rebases result in same result.

Closes #1481
This commit is contained in:
Rhys Arkins 2018-02-07 16:23:41 +01:00
parent 84fe4f2dff
commit 4c6e3f7932

View file

@ -232,7 +232,12 @@ async function writeExistingFiles(config) {
}
if (packageFile.packageLock && config.type !== 'lockFileMaintenance') {
logger.debug(`Writing package-lock.json to ${basedir}`);
const packageLock = await platform.getFile(packageFile.packageLock);
const existingPackageLock =
(await platform.branchExists(config.branchName)) &&
(await platform.getFile(packageFile.packageLock, config.branchName));
const packageLock =
existingPackageLock ||
(await platform.getFile(packageFile.packageLock));
await fs.outputFile(
upath.join(basedir, 'package-lock.json'),
packageLock
@ -242,7 +247,11 @@ async function writeExistingFiles(config) {
}
if (packageFile.yarnLock && config.type !== 'lockFileMaintenance') {
logger.debug(`Writing yarn.lock to ${basedir}`);
const yarnLock = await platform.getFile(packageFile.yarnLock);
const existingYarnLock =
(await platform.branchExists(config.branchName)) &&
(await platform.getFile(packageFile.yarnLock, config.branchName));
const yarnLock =
existingYarnLock || (await platform.getFile(packageFile.yarnLock));
await fs.outputFile(upath.join(basedir, 'yarn.lock'), yarnLock);
} else {
await fs.remove(upath.join(basedir, 'yarn.lock'));