Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Local registry bug fixed #95
Browse files Browse the repository at this point in the history
  • Loading branch information
serayuzgur committed Aug 18, 2020
1 parent 435991d commit c571495
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion sample/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ percent-encoding = "1.0.0"


[package.metadata.winrt.dependencies]
"Microsoft.Windows.SDK.Contracts" = "10.0.19041.1"
"Microsoft.Windows.SDK.Contracts" = "10.0.19041.1"

[dependencies.web-sys]
features = ['Document', 'Element', 'HtmlElement', 'Node', 'Window', 'Headers', 'Request', 'RequestInit', 'RequestMode', 'Response']
version = "*"
15 changes: 14 additions & 1 deletion src/api/local_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@ import { decidePath, parseVersions } from "./index-utils";
const exec = util.promisify(require('child_process').exec);

// check for the crates index. If none found switch to github and show error
const cargoHome = process.env.CARGO_HOME || path.resolve(os.homedir(), "/.cargo/");
const cargoHome = getCargoPath()

function getCargoPath() {
// Trailing slash on macos (does not want / at the end) and windows (needs / at end)
if (process.env.CARGO_HOME)
return process.env.CARGO_HOME;
if (os.platform() === "win32")
return path.resolve(os.homedir(), "/.cargo/");
return path.resolve(os.homedir(), ".cargo/");
}



const gitDir = path.resolve(cargoHome, "registry/index/github.com-1ecc6299db9ec823/.git/");



export function checkCargoRegistry() {
return fs.existsSync(gitDir);
}
Expand Down

0 comments on commit c571495

Please sign in to comment.