-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathupdate-locked.ts
More file actions
30 lines (29 loc) · 1.02 KB
/
update-locked.ts
File metadata and controls
30 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { logger } from '../../../logger';
import { Json } from '../../../util/schema-utils';
import { api as composer } from '../../versioning/composer';
import type { UpdateLockedConfig, UpdateLockedResult } from '../types';
import { Lockfile } from './schema';
export function updateLockedDependency(
config: UpdateLockedConfig,
): UpdateLockedResult {
const { depName, currentVersion, newVersion, lockFile, lockFileContent } =
config;
logger.debug(
`composer.updateLockedDependency: ${depName}@${currentVersion} -> ${newVersion} [${lockFile}]`,
);
try {
const lockfile = Json.pipe(Lockfile).parse(lockFileContent);
if (
lockfile?.packages.find(
({ name, version }) =>
name === depName && composer.equals(version, newVersion),
)
) {
return { status: 'already-updated' };
}
return { status: 'unsupported' };
} catch (err) /* istanbul ignore next */ {
logger.debug({ err }, 'composer.updateLockedDependency() error');
return { status: 'update-failed' };
}
}