MCPcopy
hub / github.com/freeCodeCamp/freeCodeCamp / plugin

Function plugin

tools/challenge-parser/parser/plugins/add-hooks.js:3–21  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1const { getSection } = require('./utils/get-section');
2
3function plugin() {
4 return transformer;
5
6 function transformer(tree, file) {
7 const beforeAll = getHook(tree, '--before-all--');
8 const beforeEach = getHook(tree, '--before-each--');
9 const afterEach = getHook(tree, '--after-each--');
10 const afterAll = getHook(tree, '--after-all--');
11
12 if (!beforeAll && !beforeEach && !afterEach && !afterAll) return;
13
14 file.data.hooks = file.data.hooks = {
15 ...(beforeAll && { beforeAll }),
16 ...(beforeEach && { beforeEach }),
17 ...(afterEach && { afterEach }),
18 ...(afterAll && { afterAll })
19 };
20 }
21}
22
23function getHook(tree, sectionName) {
24 const section = getSection(tree, sectionName);

Calls

no outgoing calls

Tested by

no test coverage detected