-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from suryavaddiraju/development
v2.0.8
- Loading branch information
Showing
5 changed files
with
70 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,17 @@ | ||
import * as fs from "node:fs"; | ||
import https from 'node:https'; | ||
import {existsSync,chmodSync} from "node:fs"; | ||
let package_name = ""; | ||
let offline_file = "viu"; | ||
if (process.platform==='darwin'&& process.arch==='x64'){ | ||
package_name = "viu-x86_64-apple-darwin" | ||
if (!existsSync("./bin")) { | ||
throw new Error("Platform not supported, Request to manually download the viu from rust standard installation page and place it in your system environment variables.") | ||
} | ||
else if (process.platform==='win32'&& process.arch==='x64'){ | ||
package_name = "viu-x86_64-pc-windows-msvc.exe"; | ||
offline_file = "viu.exe"; | ||
} | ||
else if (process.platform==='linux'&& process.arch==='x64'){ | ||
package_name = "viu-x86_64-unknown-linux-musl" | ||
} | ||
else if (process.platform==='linux'&& process.arch==='arm64'){ | ||
package_name = "viu-aprocess.arch64-unknown-linux-musl" | ||
} | ||
else if (process.platform==='linux'&& process.arch==='arm' && process.config.variables.arm_version === 7){ | ||
package_name = "viu-armv7-unknown-linux-musleabihf" | ||
} | ||
else if(process.platform==='linux'&& process.arch==='arm' && process.config.variables.arm_version !== 7){ | ||
package_name = "viu-arm-unknown-linux-musleabihf" | ||
if (process.platform==='win32'&& process.arch==='x64'){ | ||
package_name = "./bin/viu.exe"; | ||
} | ||
else{ | ||
throw new Error("Platform not supported, Request to manually download the viu fromrust standard installation page and place it in the bin folder.") | ||
package_name = "./bin/viu"; | ||
} | ||
const url = `https://github.com/atanunq/viu/releases/latest/download/${package_name}`; | ||
function download(url, dest) { | ||
const req = https.get(url); | ||
req.on('response', (res) => { | ||
if (res.statusCode === 200) { | ||
res.pipe(dest); | ||
} | ||
else if (res.statusCode === 302 || res.statusCode === 301) { | ||
download(res.headers.location, dest); | ||
} | ||
else{ | ||
console.error('Failed to download:', res.statusCode, res.statusMessage); | ||
} | ||
}); | ||
}; | ||
if (!fs.existsSync("./bin")) { | ||
fs.mkdirSync("./bin"); | ||
if (!existsSync(package_name)){ | ||
throw new Error("Platform not supported, Request to manually download the viu from rust standard installation page and place it in your system environment variables.") | ||
} | ||
const binaryPath = `./bin/${offline_file}`; | ||
if (!fs.existsSync(binaryPath)) { | ||
fs.closeSync(fs.openSync(binaryPath, 'w')); | ||
const file = fs.createWriteStream(binaryPath); | ||
download(url,file); | ||
fs.chmodSync(binaryPath, 0o755); | ||
}; | ||
else{ | ||
chmodSync(package_name, 0o755); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as fs from "node:fs"; | ||
import https from 'node:https'; | ||
let package_name = ""; | ||
let offline_file = "viu"; | ||
if (process.platform==='darwin'&& process.arch==='x64'){ | ||
package_name = "viu-x86_64-apple-darwin" | ||
} | ||
else if (process.platform==='win32'&& process.arch==='x64'){ | ||
package_name = "viu-x86_64-pc-windows-msvc.exe"; | ||
offline_file = "viu.exe"; | ||
} | ||
else if (process.platform==='linux'&& process.arch==='x64'){ | ||
package_name = "viu-x86_64-unknown-linux-musl" | ||
} | ||
else if (process.platform==='linux'&& process.arch==='arm64'){ | ||
package_name = "viu-aprocess.arch64-unknown-linux-musl" | ||
} | ||
else if (process.platform==='linux'&& process.arch==='arm' && process.config.variables.arm_version === 7){ | ||
package_name = "viu-armv7-unknown-linux-musleabihf" | ||
} | ||
else if(process.platform==='linux'&& process.arch==='arm' && process.config.variables.arm_version !== 7){ | ||
package_name = "viu-arm-unknown-linux-musleabihf" | ||
} | ||
else{ | ||
throw new Error("Platform not supported, Request to manually download the viu fromrust standard installation page and place it in the bin folder.") | ||
} | ||
const url = `https://github.com/atanunq/viu/releases/latest/download/${package_name}`; | ||
function download(url, dest) { | ||
const req = https.get(url); | ||
req.on('response', (res) => { | ||
if (res.statusCode === 200) { | ||
res.pipe(dest); | ||
} | ||
else if (res.statusCode === 302 || res.statusCode === 301) { | ||
download(res.headers.location, dest); | ||
} | ||
else{ | ||
console.error('Failed to download:', res.statusCode, res.statusMessage); | ||
} | ||
}); | ||
}; | ||
if (!fs.existsSync("./bin")) { | ||
fs.mkdirSync("./bin"); | ||
} | ||
const binaryPath = `./bin/${offline_file}`; | ||
if (!fs.existsSync(binaryPath)) { | ||
fs.closeSync(fs.openSync(binaryPath, 'w')); | ||
const file = fs.createWriteStream(binaryPath); | ||
download(url,file); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters