-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathoverwrite-false.js
61 lines (55 loc) · 1.36 KB
/
overwrite-false.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const t = require('tap')
const setup = require('../setup.js')
t.test('json merge', async t => {
const s = await setup(t, {
ok: true,
package: {
templateOSS: {
content: 'content',
},
},
testdir: {
content: {
'index.js': `module.exports=${JSON.stringify({
rootModule: {
add: {
'package.json': {
file: 'more-package.json',
overwrite: false,
},
},
},
})}`,
'more-package.json': JSON.stringify({
scripts: {
test: 'tap test/',
},
}),
},
},
})
await s.apply()
t.strictSame(await s.check(), [])
const pkg = await s.readJson('package.json')
t.equal(pkg.scripts.test, 'tap test/')
t.equal(pkg.scripts.snap, 'tap')
await s.writeJson('package.json', {
...pkg,
author: 'What?',
scripts: {
...pkg.scripts,
test: 'tap',
},
templateOSS: {
...pkg.templateOSS,
version: '1.0.0',
},
})
const checks = await s.check()
t.equal(checks.length, 1)
t.match(checks[0].title, 'package.json needs to be updated')
t.match(checks[0].body[0], `"author" is "What?", expected "GitHub Inc."`)
t.match(checks[0].body[0], `scripts.test" is "tap", expected "tap test/"`)
await s.apply()
t.strictSame(await s.check(), [])
})