Skip to content

Instantly share code, notes, and snippets.

@flashvnn
Created June 2, 2022 06:46
Show Gist options
  • Save flashvnn/f01488efb9ee2b8d7158f3f60b13481d to your computer and use it in GitHub Desktop.
Save flashvnn/f01488efb9ee2b8d7158f3f60b13481d to your computer and use it in GitHub Desktop.
Get php varsion requirement of Drupal contrib modules
require('total4');
const fs = require('fs');
var contrib = PATH.root() + '/../../docroot/modules/contrib'
const directories = source => fs.readdirSync(source, {
withFileTypes: true
}).reduce((a, c) => {
c.isDirectory() && a.push(c.name)
return a
}, []);
var dirs = directories(contrib)
dirs.forEach((item) => {
var path = contrib + '/' + item + '/composer.json'
var exist = fs.existsSync(path)
if (exist) {
var data = require(path)
var version = U.get(data, 'require.php')
if (version) {
console.log(item, ':', version);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment