1
|
|
|
import path from 'path'; |
2
|
|
|
import { assert } from 'chai'; |
3
|
|
|
import fs from 'fs-extra'; |
4
|
|
|
import Packer from '../entry'; |
5
|
|
|
import Test from '../Test'; |
6
|
|
|
import { tmpFolder } from '../constants'; |
7
|
|
|
|
8
|
|
|
const factory = new Test(); |
9
|
|
|
|
10
|
|
|
suite('Packer #no-pack'); |
11
|
|
|
|
12
|
|
|
before(async function () { |
13
|
|
|
await factory.setTmpFolder(); |
14
|
|
|
}); |
15
|
|
|
|
16
|
|
|
test('prepare: specify legacy versions', async function () { |
17
|
|
|
const dir = path.join(tmpFolder, 'prepare'); |
18
|
|
|
const packer = new Packer({ |
19
|
|
|
dir, |
20
|
|
|
modules : [ { name: 'eslint', legacy: '^7.0.0' } ], |
21
|
|
|
copyDefaultFiles : true, |
22
|
|
|
legacyMochaVersion : '5', |
23
|
|
|
legacyNodeVersion : '8', |
24
|
|
|
supportedNodeVersion : '14' |
25
|
|
|
}); |
26
|
|
|
|
27
|
|
|
await packer.ready; |
28
|
|
|
await packer.packModule(); |
29
|
|
|
await packer.prepare(); |
30
|
|
|
|
31
|
|
|
assert.isTrue(await fs.exists(path.join(dir, 'package.json')), 'package.json exists'); |
32
|
|
|
|
33
|
|
|
const packageJSON = await fs.readJSON(path.join(dir, 'package.json')); |
34
|
|
|
|
35
|
|
|
assert.deepOwnInclude(packageJSON, { |
36
|
|
|
legacyDependencies : { eslint: '^7.0.0' }, |
37
|
|
|
'node-package-tester' : { legacyNodeVersions: '8', nodeVersions: '14' } |
38
|
|
|
}); |
39
|
|
|
|
40
|
|
|
assert.exists(packageJSON.devDependencies.eslint); |
41
|
|
|
assert.notEqual(packageJSON.devDependencies.eslint, '^7.0.0'); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
after(async function () { |
46
|
|
|
await factory.cleanTmpFolder(); |
47
|
|
|
}); |
48
|
|
|
|