Skip to content

Commit 0d8e60c

Browse files
authored
Download based on manifest.json
1 parent 732002f commit 0d8e60c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,22 @@ async function dep() {
5959
console.log(`Downloading "https://deployer.org/deployer.phar".`)
6060
execa.commandSync('curl -LO https://deployer.org/deployer.phar')
6161
} else {
62-
if (!/^v/.test(version)) {
63-
version = 'v' + version
62+
version = version.replace(/^v/, '')
63+
let {stdout} = execa.commandSync(`curl -L https://deployer.org/manifest.json`)
64+
let manifest = JSON.parse(stdout)
65+
let url
66+
for (let asset of manifest) {
67+
if (asset.version === version) {
68+
url = asset.url
69+
break
70+
}
71+
}
72+
if (url === null) {
73+
console.error(`The version "${version}"" does not found in the "https://deployer.org/manifest.json" file."`)
74+
} else {
75+
console.log(`Downloading "${url}".`)
76+
execa.commandSync(`curl -LO ${url}`)
6477
}
65-
console.log(`Downloading "https://deployer.org/releases/${version}/deployer.phar".`)
66-
execa.commandSync(`curl -LO https://deployer.org/releases/${version}/deployer.phar`)
6778
}
6879
execa.commandSync('sudo chmod +x deployer.phar')
6980
dep = 'deployer.phar'

0 commit comments

Comments
 (0)