Skip to content

Commit

Permalink
fix: make rustup optional (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue authored Jun 18, 2024
1 parent 53f1020 commit eaf565f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/commands/new_command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async function getFileTextIfExists(path: string) {
}

async function checkIfRequiredToolsExist() {
const requiredTools = ["deno", "cargo", "rustup"];
const requiredTools = ["deno", "cargo"];
const notInstalled: string[] = [];

for (const tool of requiredTools) {
Expand Down
35 changes: 22 additions & 13 deletions lib/pre_build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,28 @@ export async function runPreBuild(

verifyVersions(crate);

console.log(
`${
colors.bold(colors.green("Ensuring"))
} wasm32-unknown-unknown target installed...`,
);

const rustupAddWasm = new Deno.Command("rustup", {
args: ["target", "add", "wasm32-unknown-unknown"],
});
const rustupAddWasmOutput = await rustupAddWasm.output();
if (!rustupAddWasmOutput.success) {
console.error(`adding wasm32-unknown-unknown target failed`);
Deno.exit(1);
try {
const rustupAddWasm = new Deno.Command("rustup", {
args: ["target", "add", "wasm32-unknown-unknown"],
});
console.log(
`${
colors.bold(colors.green("Ensuring"))
} wasm32-unknown-unknown target installed...`,
);
const rustupAddWasmOutput = await rustupAddWasm.output();
if (!rustupAddWasmOutput.success) {
console.error(`adding wasm32-unknown-unknown target failed`);
Deno.exit(1);
}
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
console.info(
`rustup not found. Ensure wasm32-unknown-unknown installed manually.`,
);
} else {
throw error;
}
}

console.log(
Expand Down

1 comment on commit eaf565f

@codegod100
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

108 commits 🙏

Please sign in to comment.