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

Commit

Permalink
Fix CLI invocation during install on some Windows systems
Browse files Browse the repository at this point in the history
  • Loading branch information
filipbudisa committed Sep 24, 2020
1 parent 94d7423 commit d4434b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions core/compiler/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import * as child_process from "child_process";

export class CLI {

public static run(args?: string[], info?: InstallInfo){
public static run(args?: string[], info?: InstallInfo | string){
let path: string;

if(info == undefined){
info = ArduinoCompiler.checkInstall();
if(info == null) return;
}else if(typeof info == "string"){
path = info;
}else{
path = info.cli;
}

const command = os.type() == "Windows_NT"
? "arduino-cli.exe"
: "./arduino-cli";

return child_process.execFileSync(command, args, { encoding: "utf8", cwd: info.cli });
return child_process.execFileSync(command, args, { encoding: "utf8", cwd: path });
}
}
6 changes: 3 additions & 3 deletions core/compiler/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ export default class Installer {

private cliInit(path, callback: (error) => void) {
try{
CLI.run(['config', 'init']);
CLI.run(['core', 'update-index']);
CLI.run(['lib', 'update-index']);
CLI.run(['config', 'init'], path);
CLI.run(['core', 'update-index'], path);
CLI.run(['lib', 'update-index'], path);
}catch(e){
logger.log("CLI init error", e);
callback(e);
Expand Down

0 comments on commit d4434b4

Please sign in to comment.