diff --git a/core/compiler/cli.ts b/core/compiler/cli.ts index c00f3bf..14e4965 100644 --- a/core/compiler/cli.ts +++ b/core/compiler/cli.ts @@ -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 }); } } \ No newline at end of file diff --git a/core/compiler/installer.ts b/core/compiler/installer.ts index 6f4ba0f..2991507 100644 --- a/core/compiler/installer.ts +++ b/core/compiler/installer.ts @@ -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);