Merge pull request #11 from Osspial/windows-uninstall-default-stable

Remove default stable install on Windows
This commit is contained in:
Héctor Ramón 2019-12-04 19:50:04 +01:00 committed by GitHub
commit a6bcfcc41f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 5 deletions

View File

@ -35,6 +35,27 @@ function install() {
// to leverage newer features like "latest latest compatible nightly"
yield exec.exec('rustup', ['self', 'update']);
yield exec.exec('rustup', ['set', 'profile', 'minimal']);
if (os.platform() == 'win32') {
let cargoPath = '';
{
const options = {
listeners: {
stdout: (data) => {
cargoPath += data.toString();
}
}
};
yield exec.exec('where', ['rustup.exe'], options);
}
let rustupPath = cargoPath.split('\\').slice(0, -3).concat([".rustup"]).join("\\");
let defaultClearedFilePath = `${rustupPath}\\default_cleared`;
if (!fs_1.existsSync(defaultClearedFilePath)) {
// 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.
fs_1.renameSync(`${rustupPath}\\toolchains`, `${rustupPath}\\_toolchains`);
fs_1.appendFileSync(defaultClearedFilePath, '');
}
}
}
});
}

6
package-lock.json generated
View File

@ -633,9 +633,9 @@
"dev": true
},
"@types/node": {
"version": "12.6.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.6.9.tgz",
"integrity": "sha512-+YB9FtyxXGyD54p8rXwWaN1EWEyar5L58GlGWgtH2I9rGmLGBQcw63+0jw+ujqVavNuO47S1ByAjm9zdHMnskw==",
"version": "12.12.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz",
"integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==",
"dev": true
},
"@types/semver": {

View File

@ -30,7 +30,7 @@
},
"devDependencies": {
"@types/jest": "^24.0.13",
"@types/node": "^12.0.4",
"@types/node": "^12.12.14",
"@types/semver": "^6.0.0",
"jest": "^24.8.0",
"jest-circus": "^24.7.1",

View File

@ -3,7 +3,7 @@ import * as exec from '@actions/exec';
import * as toolCache from '@actions/tool-cache';
import * as path from 'path';
import * as os from 'os';
import {chmodSync} from 'fs';
import {chmodSync, renameSync, existsSync, appendFileSync} from 'fs';
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
@ -20,6 +20,29 @@ export async function install() {
await exec.exec('rustup', ['self', 'update']);
await exec.exec('rustup', ['set', 'profile', 'minimal']);
if (os.platform() == 'win32') {
let cargoPath = '';
{
const options = {
listeners: {
stdout: (data: Buffer) => {
cargoPath += data.toString();
}
}
};
await exec.exec('where', ['rustup.exe'], options);
}
let rustupPath = cargoPath.split('\\').slice(0, -3).concat([".rustup"]).join("\\");
let defaultClearedFilePath = `${rustupPath}\\default_cleared`;
if (!existsSync(defaultClearedFilePath)) {
// 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.
renameSync(`${rustupPath}\\toolchains`, `${rustupPath}\\_toolchains`);
appendFileSync(defaultClearedFilePath, '');
}
}
}
}