Skip to content

Commit 749809b

Browse files
authored
Merge pull request #63 from boesing/bugfix/do-not-require-composer-json
Do not require `composer.json` to be available
2 parents 6cbe6be + f9c83c6 commit 749809b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ function parseConfig (configFile) {
3737
* @return {Object}
3838
*/
3939
function parseComposerJson (composerJsonFile) {
40+
if (!fs.existsSync(composerJsonFile)) {
41+
return {};
42+
}
43+
4044
try {
4145
return JSON.parse(fs.readFileSync(composerJsonFile));
4246
} catch (error) {
@@ -49,7 +53,12 @@ function parseComposerJson (composerJsonFile) {
4953
* @return {Array}
5054
*/
5155
function gatherVersions (composerJson) {
56+
if (JSON.stringify(composerJson) === '{}') {
57+
return [];
58+
}
59+
5260
let versions = [];
61+
5362
INSTALLABLE_VERSIONS.forEach(function (version) {
5463
if (semver.satisfies(version + '.0', composerJson['require']['php'])) {
5564
versions.push(version);

0 commit comments

Comments
 (0)