Try using environment variables

This commit is contained in:
Osspial 2019-12-04 02:25:23 -05:00
parent 69d806023a
commit 468970f930
2 changed files with 34 additions and 28 deletions

View File

@ -38,20 +38,22 @@ function install() {
yield exec.exec('rustup', ['self', 'update']); yield exec.exec('rustup', ['self', 'update']);
yield exec.exec('rustup', ['set', 'profile', 'minimal']); yield exec.exec('rustup', ['set', 'profile', 'minimal']);
if (os.platform() == 'win32') { if (os.platform() == 'win32') {
let rustDocsInstalled = false; let clearedEnvVar = '__SETUP_RUST_ACTION_DEFAULT_INSTALL_CLEARED';
{ // let rustDocsInstalled = false;
let installedComponents = ''; // {
const options = { // let installedComponents = '';
listeners: { // const options = {
stdout: (data) => { // listeners: {
installedComponents += data.toString(); // stdout: (data: Buffer) => {
} // installedComponents += data.toString();
} // }
}; // }
yield exec.exec('rustup', ['component', 'list'], options); // };
rustDocsInstalled = installedComponents.match(/rust-docs.+\(installed\)/) != null; // await exec.exec('rustup', ['component', 'list'], options);
} // rustDocsInstalled = installedComponents.match(/rust-docs.+\(installed\)/) != null;
if (rustDocsInstalled) { // }
// If the rust-docs component isn't installed,
if (process.env[clearedEnvVar] == null) {
let cargoPath = ''; let cargoPath = '';
{ {
const options = { const options = {
@ -67,6 +69,7 @@ function install() {
// Github's default Windows install comes with rustup pre-installed with stable, including // Github's default Windows install comes with rustup pre-installed with stable, including
// rust-docs. This removes the default stable install so that it doesn't update rust-docs. // rust-docs. This removes the default stable install so that it doesn't update rust-docs.
yield renameAsync(`${rustupPath}\\toolchains`, `${rustupPath}\\_toolchains`); yield renameAsync(`${rustupPath}\\toolchains`, `${rustupPath}\\_toolchains`);
yield exec.exec('setx', [clearedEnvVar, "1"]);
} }
} }
} }

View File

@ -24,21 +24,23 @@ export async function install() {
await exec.exec('rustup', ['set', 'profile', 'minimal']); await exec.exec('rustup', ['set', 'profile', 'minimal']);
if (os.platform() == 'win32') { if (os.platform() == 'win32') {
let rustDocsInstalled = false; let clearedEnvVar = '__SETUP_RUST_ACTION_DEFAULT_INSTALL_CLEARED';
{ // let rustDocsInstalled = false;
let installedComponents = ''; // {
const options = { // let installedComponents = '';
listeners: { // const options = {
stdout: (data: Buffer) => { // listeners: {
installedComponents += data.toString(); // stdout: (data: Buffer) => {
} // installedComponents += data.toString();
} // }
}; // }
await exec.exec('rustup', ['component', 'list'], options); // };
rustDocsInstalled = installedComponents.match(/rust-docs.+\(installed\)/) != null; // await exec.exec('rustup', ['component', 'list'], options);
} // rustDocsInstalled = installedComponents.match(/rust-docs.+\(installed\)/) != null;
// }
if (rustDocsInstalled) { // If the rust-docs component isn't installed,
if (process.env[clearedEnvVar] == null) {
let cargoPath = ''; let cargoPath = '';
{ {
const options = { const options = {
@ -54,6 +56,7 @@ export async function install() {
// Github's default Windows install comes with rustup pre-installed with stable, including // Github's default Windows install comes with rustup pre-installed with stable, including
// rust-docs. This removes the default stable install so that it doesn't update rust-docs. // rust-docs. This removes the default stable install so that it doesn't update rust-docs.
await renameAsync(`${rustupPath}\\toolchains`, `${rustupPath}\\_toolchains`); await renameAsync(`${rustupPath}\\toolchains`, `${rustupPath}\\_toolchains`);
await exec.exec('setx', [clearedEnvVar, "1"]);
} }
} }
} }