MCPcopy Create free account
hub / github.com/parse-community/parse-server / getPackageFiles

Method getPackageFiles

ci/nodeEngineCheck.js:40–61  ·  view source on GitHub ↗

* Returns an array of `package.json` files under the given path and subdirectories. * @param {String} [basePath] The base path for recursive directory search.

(basePath = this.nodeModulesPath)

Source from the content-addressed store, hash-verified

38 * @param {String} [basePath] The base path for recursive directory search.
39 */
40 async getPackageFiles(basePath = this.nodeModulesPath) {
41 try {
42 // Declare file list
43 const files = []
44
45 // Get files
46 const dirents = await fs.readdir(basePath, { withFileTypes: true });
47 const validFiles = dirents.filter(d => d.name.toLowerCase() == 'package.json').map(d => path.join(basePath, d.name));
48 files.push(...validFiles);
49
50 // For each directory entry
51 for (const dirent of dirents) {
52 if (dirent.isDirectory()) {
53 const subFiles = await this.getPackageFiles(path.join(basePath, dirent.name));
54 files.push(...subFiles);
55 }
56 }
57 return files;
58 } catch (e) {
59 throw `Failed to get package.json files in ${this.nodeModulesPath} with error: ${e}`;
60 }
61 }
62
63 /**
64 * Extracts and returns the node engine versions of the given package.json

Callers 1

checkFunction · 0.95

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected