-
Notifications
You must be signed in to change notification settings - Fork 1
/
coverage:replace-nyc-by-c8.js
47 lines (39 loc) · 1.07 KB
/
coverage:replace-nyc-by-c8.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as pkg from '../lib/pkg.js';
import update from '../lib/update.js';
export const description = 'Use c8 instead of nyc.';
export const commit = {
subject: description,
};
const oldDep = 'nyc';
const newDep = 'c8';
export async function postcondition({readPkg, assert}) {
const pkgjson = await readPkg();
const devDeps = pkg.devDeps(pkgjson);
assert(!devDeps.has(oldDep));
assert(devDeps.has(newDep));
}
export async function precondition({readPkg, assert}) {
const pkgjson = await readPkg();
const devDeps = pkg.devDeps(pkgjson);
assert(devDeps.has(oldDep));
assert(!devDeps.has(newDep));
}
export async function apply({readPkg, writePkg, upgrade, fixConfig, install}) {
// Update package.json
await update({
read: readPkg,
write: writePkg,
edit: (pkgjson) => {
pkg.replaceDep(pkgjson, oldDep, newDep);
pkgjson.scripts.cover = pkgjson.scripts.cover.replace(
oldDep,
`${newDep} --all --src src`,
);
return pkgjson;
},
});
await upgrade(newDep);
await fixConfig();
await install();
}
export const dependencies = ['config:lint-setup'];