2020-07-21 12:52:24 +00:00
|
|
|
import Git from 'simple-git';
|
2020-11-04 13:37:52 +00:00
|
|
|
import upath from 'upath';
|
2019-11-28 19:04:54 +00:00
|
|
|
|
2020-02-06 13:01:21 +00:00
|
|
|
import { UpdateDependencyConfig } from '../common';
|
2019-11-28 19:04:54 +00:00
|
|
|
|
2020-02-06 13:01:21 +00:00
|
|
|
export default async function updateDependency({
|
|
|
|
fileContent,
|
|
|
|
upgrade,
|
|
|
|
}: UpdateDependencyConfig): Promise<string | null> {
|
2019-11-28 19:04:54 +00:00
|
|
|
const git = Git(upgrade.localDir);
|
2020-11-04 13:37:52 +00:00
|
|
|
const submoduleGit = Git(upath.join(upgrade.localDir, upgrade.depName));
|
2019-11-28 19:04:54 +00:00
|
|
|
|
|
|
|
try {
|
2020-11-04 13:37:52 +00:00
|
|
|
await git.submoduleUpdate(['--init', upgrade.depName]);
|
2021-02-16 11:33:44 +00:00
|
|
|
await submoduleGit.checkout([upgrade.newVersion]);
|
2019-11-28 19:04:54 +00:00
|
|
|
return fileContent;
|
|
|
|
} catch (err) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|