-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathprepare-transloadit.test.ts
More file actions
76 lines (64 loc) · 2.25 KB
/
prepare-transloadit.test.ts
File metadata and controls
76 lines (64 loc) · 2.25 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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { describe, expect, it } from 'vitest'
import { shouldReusePreparedNodeDist } from '../../../../scripts/prepare-node-package.ts'
import { buildLegacyPackageJson } from '../../../../scripts/prepare-transloadit.ts'
describe('prepare-transloadit', () => {
it('preserves an existing transloadit-only version bump', () => {
const nodePackageJson = {
name: '@transloadit/node',
version: '4.8.1',
scripts: {
check: 'yarn lint && yarn fix',
'test:unit': 'vitest run --coverage ./test/unit',
'test:e2e': 'vitest run ./test/e2e',
test: 'vitest run --coverage',
},
devDependencies: {
vitest: '^3.2.4',
},
bin: {
transloadit: './dist/cli.js',
},
publishConfig: {
tag: 'beta',
},
}
const legacyExisting = {
name: 'transloadit',
version: '4.8.2',
devDependencies: {
vitest: '^3.2.4',
},
}
const legacyPackageJson = buildLegacyPackageJson(nodePackageJson, legacyExisting)
expect(legacyPackageJson.name).toBe('transloadit')
expect(legacyPackageJson.version).toBe('4.8.2')
expect(legacyPackageJson.bin).toBe('./dist/cli.js')
expect(legacyPackageJson.publishConfig).toBeUndefined()
})
it('falls back to the node package version when no legacy package exists yet', () => {
const nodePackageJson = {
name: '@transloadit/node',
version: '4.8.1',
scripts: {},
devDependencies: {},
}
const legacyPackageJson = buildLegacyPackageJson(nodePackageJson, null)
expect(legacyPackageJson.version).toBe('4.8.1')
})
it('only reuses a prepared node dist during the explicit publish flow', () => {
const original = process.env.TRANSLOADIT_PUBLISH_PREBUILT_NODE
try {
expect(shouldReusePreparedNodeDist(false)).toBe(false)
process.env.TRANSLOADIT_PUBLISH_PREBUILT_NODE = 'true'
expect(shouldReusePreparedNodeDist(true)).toBe(true)
delete process.env.TRANSLOADIT_PUBLISH_PREBUILT_NODE
expect(shouldReusePreparedNodeDist(true)).toBe(false)
} finally {
if (original == null) {
delete process.env.TRANSLOADIT_PUBLISH_PREBUILT_NODE
} else {
process.env.TRANSLOADIT_PUBLISH_PREBUILT_NODE = original
}
}
})
})