const fs = require("fs");
const path = require("path");
const { exec } = require("child_process");
const { homedir } = require("os");
const cargoDir = path.join(homedir(), ".cargo");
if (fs.existsSync(cargoDir)) {
} else {
const setCargo = 'PATH="/$HOME/.cargo/bin:${PATH}"';
console.log("Installing deps [cargo].");
exec(
`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && ${setCargo}`,
(error) => {
if (error) {
console.log(
"curl failed! Curl may not be installed on the OS. View https://curl.se/download.html to install."
);
console.log(error);
}
}
);
}
const features = process.env.npm_config_features ? `--features ${process.env.npm_config_features.replace(",", " ")}` : "";
console.log(`Installing and compiling utils 0.5.22 ${features} ...`);
exec(`cargo install utils --vers 0.5.22 ${features}`, (error, stdout, stderr) => {
console.log(stdout);
if (error || stderr) {
console.log(error || stderr);
} else {
console.log("install finished!");
}
});