MCPcopy Create free account
hub / github.com/parse-community/parse-dashboard / getNodeVersion

Method getNodeVersion

ci/nodeEngineCheck.mjs:76–110  ·  view source on GitHub ↗

* Extracts and returns the node engine versions of the given package.json * files. * @param {Object} config * @param {String[]} config.files The package.json files. * @param {Boolean} config.clean Is true if packages with undefined node versions * should be removed from the results.

({ files, ignoredFilePaths = [], clean = false })

Source from the content-addressed store, hash-verified

74 * @returns {Object[]} A list of results.
75 */
76 async getNodeVersion({ files, ignoredFilePaths = [], clean = false }) {
77
78 // Declare response
79 let response = [];
80
81 // For each file
82 for (const file of files) {
83 const shouldFileBeIgnored = ignoredFilePaths.find((path) => path.test(file)) !== undefined;
84
85 if (shouldFileBeIgnored) {
86 continue;
87 }
88
89 try {
90 // Get node version
91 const contentString = await fs.readFile(file, 'utf-8');
92 const contentJson = JSON.parse(contentString);
93 const version = ((contentJson || {}).engines || {}).node;
94
95 // Add response
96 response.push({
97 file: file,
98 nodeVersion: version
99 });
100 } catch (err) {
101 throw `Failed to parse package at ${file} with error ${err}`;
102 }
103 }
104
105 // If results should be cleaned by removing undefined node versions
106 if (clean) {
107 response = response.filter(r => r.nodeVersion !== undefined);
108 }
109 return response;
110 }
111
112 /**
113 * Returns the highest semver definition that satisfies all versions

Callers 2

getParentVersionMethod · 0.95
checkFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected