MCPcopy
hub / github.com/ampproject/amphtml / getTaskFunc

Function getTaskFunc

build-system/task-runner/amp-task-runner.js:155–163  ·  view source on GitHub ↗

* Returns a task function after making sure it is valid. * @param {string} taskSourceFileName * @param {string} taskFuncName * @return {TaskFuncDef}

(taskSourceFileName, taskFuncName)

Source from the content-addressed store, hash-verified

153 * @return {TaskFuncDef}
154 */
155function getTaskFunc(taskSourceFileName, taskFuncName) {
156 const taskSourceFilePath = getTaskSourceFilePath(taskSourceFileName);
157 const taskFunc = require(taskSourceFilePath)[taskFuncName];
158 const isValidFunc = typeof taskFunc == 'function';
159 if (!isValidFunc) {
160 handleInvalidTaskError(taskSourceFileName, taskFuncName);
161 }
162 return taskFunc;
163}
164
165/**
166 * Uses esprima to extract the description from a task file without require-ing

Callers 1

createTaskFunction · 0.85

Calls 2

getTaskSourceFilePathFunction · 0.85
handleInvalidTaskErrorFunction · 0.85

Tested by

no test coverage detected