diff --git a/lib/rustup.js b/lib/rustup.js index e3d06ee..243ca64 100644 --- a/lib/rustup.js +++ b/lib/rustup.js @@ -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, ''); + } + } } }); } diff --git a/package-lock.json b/package-lock.json index 59e4a7d..ed0f22a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/package.json b/package.json index 21b06c3..fcbecae 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/rustup.ts b/src/rustup.ts index 1613512..15013f0 100644 --- a/src/rustup.ts +++ b/src/rustup.ts @@ -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, ''); + } + } } }