Skip to content

Commit

Permalink
Merge pull request #11 from Osspial/windows-uninstall-default-stable
Browse files Browse the repository at this point in the history
Remove default stable install on Windows
  • Loading branch information
hecrj authored Dec 4, 2019
2 parents a82cf6b + de871ef commit a6bcfcc
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
21 changes: 21 additions & 0 deletions lib/rustup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
}
}
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 24 additions & 1 deletion src/rustup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] || '';

Expand All @@ -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, '');
}
}
}
}

Expand Down

0 comments on commit a6bcfcc

Please sign in to comment.