Files
2026-07-31 13:12:54 -04:00

23 lines
755 B
JavaScript

import fs from 'node:fs';
import path from 'node:path';
export function readComposerJson(root) {
const file = path.join(root, 'composer.json');
if (!fs.existsSync(file))
return null;
try {
return JSON.parse(fs.readFileSync(file, 'utf8'));
}
catch {
return null;
}
}
export function hasComposerDependency(pkg, name) {
if (!pkg)
return false;
return Boolean(pkg.require?.[name] || pkg['require-dev']?.[name]);
}
export function vendorBinExists(root, bin) {
const suffix = process.platform === 'win32' ? '.bat' : '';
return fs.existsSync(path.join(root, 'vendor', 'bin', `${bin}${suffix}`)) || fs.existsSync(path.join(root, 'vendor', 'bin', bin));
}
//# sourceMappingURL=composer.js.map