Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
fix: compat install yvm
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Ogbizi committed May 25, 2019
1 parent 2789af9 commit 6faffbd
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,33 @@ async function saveVersion(version, yvmPath) {
fs.writeFileSync(filePath, JSON.stringify({ version }))
}

async function compatInstall({ paths, version }) {
log(`Compatibility install: ${version.downloadUrl}`)
const yvmCompatInstallScript = 'yvm-install-script'
const yvmCompatDownloadPath = `https://raw.githubusercontent.com/tophat/yvm/${
version.tagName
}/scripts/install.`
for (const [source, envBin] of [
[`${yvmCompatDownloadPath}js`, 'node'],
[`${yvmCompatDownloadPath}sh`, 'bash'],
]) {
try {
await downloadFile({ source, destination: yvmCompatInstallScript })
execSync(
`YVM_INSTALL_DIR='${paths.yvm}' INSTALL_VERSION='${
version.tagName
}' ${envBin} ${yvmCompatInstallScript}`,
)
.toString()
.split('\n')
.forEach(l => log(l))
return fs.unlinkSync(yvmCompatInstallScript)
} catch (e) {
continue
}
}
}

async function run() {
const config = getConfig()
const { version, paths, useLocal } = config
Expand All @@ -222,24 +249,8 @@ async function run() {
log('Querying github release API to determine latest version')
Object.assign(version, await getLatestYvmVersion(releaseApiUrl))
}
if (version.downloadUrl.endsWith('yvm.zip')) {
log(`Compatibility install: ${version.downloadUrl}`)
const yvmCompatInstallScript = 'yvm-install.sh'
await downloadFile({
source: `https://raw.githubusercontent.com/tophat/yvm/${
version.tagName
}/scripts/install.sh`,
destination: yvmCompatInstallScript,
})
execSync(
`YVM_INSTALL_DIR='${paths.yvm}' INSTALL_VERSION='${
version.tagName
}' bash ${yvmCompatInstallScript}`,
)
.toString()
.split('\n')
.forEach(l => log(l))
return fs.unlinkSync(yvmCompatInstallScript)
if (version.downloadUrl.endsWith(zipFile)) {
return compatInstall({ paths, version })
}
await downloadFile({
source: version.downloadUrl,
Expand Down

0 comments on commit 6faffbd

Please sign in to comment.