Skip to content

Commit 1093dfd

Browse files
authored
Support base dependency in object form (#11)
1 parent be4eaa1 commit 1093dfd

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

examples/package-equal-or-less-than.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: my-haskell-package
22
version: 0.1.0.0
3-
dependencies: [base >= 4.10 && <= 4.15, containers, text]
3+
4+
dependencies:
5+
- name: base
6+
version: '>= 4.10 && <= 4.15'
7+
- containers
8+
- text
49

510
library:
611
exposed-modules: MyLib

src/index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,30 @@ function parseBaseUpperBound(packageYamlPath) {
6363
throw new Error("dependencies not found or invalid in package.yaml");
6464
}
6565

66-
const baseDep = deps.find(dep => dep.startsWith("base"));
66+
const baseDep = deps.find(dep => {
67+
if (typeof dep === "string") {
68+
return dep.startsWith("base");
69+
} else if (typeof dep === "object" && dep.name) {
70+
return dep.name === "base";
71+
}
72+
return false;
73+
});
74+
6775
if (!baseDep) {
6876
githubCore.setFailed("No base dependency found in package.yaml");
77+
return;
78+
}
79+
80+
let versionConstraint;
81+
if (typeof baseDep === "string") {
82+
versionConstraint = getBaseUpperBound(baseDep);
83+
} else if (typeof baseDep === "object") {
84+
versionConstraint = getBaseUpperBound(baseDep.version);
6985
}
7086

71-
const versionConstraint = getBaseUpperBound(baseDep);
7287
if (!versionConstraint) {
7388
githubCore.setFailed("No upper bound for base found in package.yaml");
89+
return;
7490
}
7591

7692
return versionConstraint;

0 commit comments

Comments
 (0)