-
-
Notifications
You must be signed in to change notification settings - Fork 556
/
yarn.js
35 lines (29 loc) 路 999 Bytes
/
yarn.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
const { readFileSync, writeFileSync } = require('fs');
const { join } = require('path');
const test = require('ava');
const del = require('del');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const { rollup } = require('rollup');
const autoInstall = require('..');
const cwd = join(__dirname, 'fixtures/yarn');
const file = join(cwd, 'output/bundle.js');
const input = join(cwd, '../input.js');
process.chdir(cwd);
test('yarn', async (t) => {
await rollup({
input,
output: {
file,
format: 'cjs'
},
// mock the call to yarn here. yarn has had consistent issues in this test env
plugins: [autoInstall({ commands: { yarn: 'echo yarn > yarn.lock' } }), nodeResolve()]
});
const lockFile = readFileSync('yarn.lock', 'utf-8');
// snapshots for this are a nightmare cross-platform
t.truthy(/yarn\s+node-noop/.test(lockFile));
});
test.after(async () => {
await del(['node_modules', 'package.json']);
writeFileSync('yarn.lock', '');
});