Skip to content

Commit

Permalink
chore(repo): update post install script to manually check for rust ve…
Browse files Browse the repository at this point in the history
…rsion less than 1.70 (#19739)
  • Loading branch information
Cammisuli authored Oct 19, 2023
1 parent ef4ffe9 commit 93e1e1b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions scripts/preinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,37 @@
This pre-install script will check that the necessary dependencies are installed
Checks for:
* Node 18+
* Cargo
* Rust
*/

if (process.env.CI) {
process.exit(0);
}

const childProcess = require('child_process');
const semverLessThan = require('semver/functions/lt');

// Check node version
const nodeVersion = process.version.slice(1).split('.');
if (+nodeVersion[0] < 18) {
if (semverLessThan(process.version, '18.0.0')) {
console.error(
'Please make sure that your installed Node version is greater than v18'
);
process.exit(1);
}

// Check for cargo
// Check for rust
try {
childProcess.execSync('cargo --version');
let rustVersion = childProcess.execSync('rustc --version');
if (semverLessThan(rustVersion.toString().split(' ')[1], '1.70.0')) {
console.log(`Found ${rustVersion}`);
console.error(
'Please make sure that your installed Rust version is greater than v1.70. You can update your installed Rust version with `rustup update`'
);
process.exit(1);
}
} catch {
console.error(
'Could not find Cargo. Please make sure that Cargo and Rust is installed with https://rustup.rs'
'Could not find the Rust compiler on this system. Please make sure that it is installed with https://rustup.rs'
);
process.exit(1);
}

0 comments on commit 93e1e1b

Please sign in to comment.