-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
yarn.test.js
84 lines (72 loc) · 2.02 KB
/
yarn.test.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* @flow */
const {delimiter} = require(`path`);
const {
tests: {generatePkgDriver, startPackageServer, getPackageRegistry},
exec: {execFile},
} = require(`pkg-tests-core`);
const {
basic: basicSpecs,
dragon: dragonSpecs,
lock: lockSpecs,
pnp: pnpSpecs,
pnpapiV1: pnpapiV1Specs,
script: scriptSpecs,
workspace: workspaceSpecs,
} = require(`pkg-tests-specs`);
const pkgDriver = generatePkgDriver({
async runDriver(
path,
[command, ...args],
{cwd, projectFolder, registryUrl, plugNPlay, plugnplayShebang, plugnplayBlacklist, env},
) {
let beforeArgs = [];
let middleArgs = [];
if (projectFolder) {
beforeArgs = [...beforeArgs, `--cwd`, projectFolder];
}
if (command === 'install') {
middleArgs = [...middleArgs, `--cache-folder`, `${path}/.cache`];
}
const res = await execFile(
process.execPath,
[`${process.cwd()}/../../bin/yarn.js`, ...beforeArgs, command, ...middleArgs, ...args],
{
env: Object.assign(
{
[`NPM_CONFIG_REGISTRY`]: registryUrl,
[`YARN_SILENT`]: `1`,
[`YARN_PROXY`]: ``,
[`YARN_HTTPS_PROXY`]: ``,
[`YARN_PLUGNPLAY_SHEBANG`]: plugnplayShebang || ``,
[`YARN_PLUGNPLAY_BLACKLIST`]: plugnplayBlacklist || ``,
[`PATH`]: `${path}/bin${delimiter}${process.env.PATH}`,
},
plugNPlay ? {[`YARN_PLUGNPLAY_OVERRIDE`]: plugNPlay ? `1` : `0`} : {},
env,
),
cwd: cwd || path,
},
);
if (process.env.JEST_LOG_SPAWNS) {
console.log(`===== stdout:`);
console.log(res.stdout);
console.log(`===== stderr:`);
console.log(res.stderr);
}
return res;
},
});
if (process.platform === `win32`) {
jest.setTimeout(10000);
}
beforeEach(async () => {
await startPackageServer();
await getPackageRegistry();
});
basicSpecs(pkgDriver);
lockSpecs(pkgDriver);
scriptSpecs(pkgDriver);
workspaceSpecs(pkgDriver);
pnpSpecs(pkgDriver);
pnpapiV1Specs(pkgDriver);
dragonSpecs(pkgDriver);