MCPcopy Create free account
hub / github.com/appium/appium / parseRequirementsTxt

Method parseRequirementsTxt

packages/docutils/lib/validate.ts:208–229  ·  view source on GitHub ↗

* Parses a `requirements.txt` file and returns an array of packages * * Caches the result. * @returns List of package data w/ name and version

()

Source from the content-addressed store, hash-verified

206 * @returns List of package data w/ name and version
207 */
208 protected async parseRequirementsTxt(): Promise<PipPackage[]> {
209 if (this.requirementsTxt) {
210 return this.requirementsTxt;
211 }
212
213 const requiredPackages: PipPackage[] = [];
214
215 try {
216 let requirementsTxt = await fs.readFile(REQUIREMENTS_TXT_PATH, 'utf8');
217 requirementsTxt = requirementsTxt.trim();
218 log.debug('Raw %s: %s', NAME_REQUIREMENTS_TXT, requirementsTxt);
219 for (const line of requirementsTxt.split(/\r?\n/)) {
220 const [name, version] = line.trim().split('==');
221 requiredPackages.push({name, version});
222 }
223 log.debug('Parsed %s: %O', NAME_REQUIREMENTS_TXT, requiredPackages);
224 } catch (e) {
225 throw new DocutilsError(`Could not find ${REQUIREMENTS_TXT_PATH}. This is a bug`, {cause: e});
226 }
227
228 return (this.requirementsTxt = requiredPackages);
229 }
230
231 /**
232 * Resets the cache of emitted errors

Callers 2

validateMkDocsMethod · 0.95
validatePythonDepsMethod · 0.95

Calls 2

pushMethod · 0.80
debugMethod · 0.65

Tested by

no test coverage detected