mirror of
https://github.com/zhigang1992/yarn.git
synced 2026-04-27 00:05:05 +08:00
* feat(install): Implement a very basic hook system This PR adds a very basic and undocumented hook system. I plan to use it internally to get better stats on how Yarn performs, and how much time is spent on the linking step. * Adds tests * Improves the typing of callThroughHook * Lints
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
/* @flow */
|
|
|
|
import {runInstall} from './commands/_helpers.js';
|
|
|
|
test('install should call the resolveStep hook', async () => {
|
|
global.experimentalYarnHooks = {
|
|
resolveStep: jest.fn(cb => cb()),
|
|
};
|
|
await runInstall({}, 'install-production', config => {
|
|
expect(global.experimentalYarnHooks.resolveStep.mock.calls.length).toEqual(1);
|
|
});
|
|
delete global.experimentalYarnHooks;
|
|
});
|
|
|
|
test('install should call the fetchStep hook', async () => {
|
|
global.experimentalYarnHooks = {
|
|
fetchStep: jest.fn(cb => cb()),
|
|
};
|
|
await runInstall({}, 'install-production', config => {
|
|
expect(global.experimentalYarnHooks.fetchStep.mock.calls.length).toEqual(1);
|
|
});
|
|
delete global.experimentalYarnHooks;
|
|
});
|
|
|
|
test('install should call the linkStep hook', async () => {
|
|
global.experimentalYarnHooks = {
|
|
linkStep: jest.fn(cb => cb()),
|
|
};
|
|
await runInstall({}, 'install-production', config => {
|
|
expect(global.experimentalYarnHooks.linkStep.mock.calls.length).toEqual(1);
|
|
});
|
|
delete global.experimentalYarnHooks;
|
|
});
|
|
|
|
test('install should call the buildStep hook', async () => {
|
|
global.experimentalYarnHooks = {
|
|
buildStep: jest.fn(cb => cb()),
|
|
};
|
|
await runInstall({}, 'install-production', config => {
|
|
expect(global.experimentalYarnHooks.buildStep.mock.calls.length).toEqual(1);
|
|
});
|
|
delete global.experimentalYarnHooks;
|
|
});
|