Skip to content

Commit 00e86eb

Browse files
Use latest version if version option is not specified
1 parent 18ed667 commit 00e86eb

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/commands/test.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,22 @@ module.exports = {
7777
return
7878
}
7979

80+
let result = await fetch('https://api.github.com/repos/LimeChain/matchstick/releases/latest')
81+
let json = await result.json()
82+
let latest_version = json.tag_name
83+
8084
if(docker_opt) {
81-
runDocker(coverage_opt, datasource, version_opt, print)
85+
runDocker(coverage_opt, datasource, version_opt, latest_version, print)
8286
} else {
83-
runBinary(coverage_opt, datasource, force_opt, logs_opt, version_opt, print)
87+
runBinary(coverage_opt, datasource, force_opt, logs_opt, version_opt, latest_version, print)
8488
}
8589
}
8690
}
8791

88-
async function runBinary(coverage_opt, datasource, force_opt, logs_opt, version_opt, print) {
92+
async function runBinary(coverage_opt, datasource, force_opt, logs_opt, version_opt, latest_version, print) {
8993
const platform = getPlatform(logs_opt)
9094

91-
if (!version_opt) {
92-
let result = await fetch('https://api.github.com/repos/LimeChain/matchstick/releases/latest')
93-
let json = await result.json()
94-
version_opt = json.tag_name
95-
}
96-
97-
const url = `https://github.com/LimeChain/matchstick/releases/download/${version_opt}/${platform}`
95+
const url = `https://github.com/LimeChain/matchstick/releases/download/${version_opt || latest_version}/${platform}`
9896

9997
if (logs_opt) {
10098
console.log(`Download link: ${url}`)
@@ -144,7 +142,7 @@ function getPlatform(logs_opt) {
144142
throw new Error(`Unsupported platform: ${type} ${arch} ${majorVersion}`)
145143
}
146144

147-
function runDocker(coverage_opt, datasource, version_opt, print) {
145+
function runDocker(coverage_opt, datasource, version_opt, latest_version, print) {
148146
// Remove binary-install-raw binaries, because docker has permission issues
149147
// when building the docker images
150148
fs.rmSync("node_modules/binary-install-raw/bin", { force: true, recursive: true });
@@ -156,7 +154,7 @@ function runDocker(coverage_opt, datasource, version_opt, print) {
156154
}
157155

158156
try {
159-
fs.writeFileSync(`${dir}/Dockerfile`, dockerfile(version_opt))
157+
fs.writeFileSync(`${dir}/Dockerfile`, dockerfile(version_opt, latest_version))
160158
print.info('Successfully generated Dockerfile.');
161159
} catch (error) {
162160
print.info('A problem occurred while generating the Dockerfile. Please attend to the errors below:');
@@ -217,7 +215,7 @@ function runDocker(coverage_opt, datasource, version_opt, print) {
217215
}
218216

219217
// TODO: Move these in separate file (in a function maybe)
220-
function dockerfile(version_opt) {
218+
function dockerfile(version_opt, latest_version) {
221219
return `
222220
FROM ubuntu:20.04
223221
ENV ARGS=""
@@ -232,7 +230,7 @@ function dockerfile(version_opt) {
232230
RUN npm install -g @graphprotocol/graph-cli
233231
234232
# Download the latest linux binary
235-
RUN curl -OL https://github.com/LimeChain/matchstick/releases/download/${version_opt || "0.2.2a"}/binary-linux-20
233+
RUN curl -OL https://github.com/LimeChain/matchstick/releases/download/${version_opt || latest_version}/binary-linux-20
236234
237235
# Make it executable
238236
RUN chmod a+x binary-linux-20

0 commit comments

Comments
 (0)