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

Function getTaskSourceFilePath

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

* Returns a task's source file path after making sure it is either a valid JS * file or a valid dir. * @param {string} taskSourceFileName * @return {string}

(taskSourceFileName)

Source from the content-addressed store, hash-verified

135 * @return {string}
136 */
137function getTaskSourceFilePath(taskSourceFileName) {
138 const tasksDir = path.join(__dirname, '..', 'tasks');
139 const taskSourceFilePath = path.join(tasksDir, taskSourceFileName);
140 const isValidSourceFilePath =
141 fs.pathExistsSync(`${taskSourceFilePath}.js`) || // Task lives in a JS file.
142 fs.pathExistsSync(taskSourceFilePath); // Task lives in a directory.
143 if (!isValidSourceFilePath) {
144 handleInvalidTaskError(taskSourceFileName);
145 }
146 return taskSourceFilePath;
147}
148
149/**
150 * Returns a task function after making sure it is valid.

Callers 3

ensureUpdatedPackagesFunction · 0.85
getTaskFuncFunction · 0.85
getTaskDescriptionFunction · 0.85

Calls 1

handleInvalidTaskErrorFunction · 0.85

Tested by

no test coverage detected