in src/arduino/arduino.ts [237:287]
public async installBoard(packageName: string, arch: string = "", version: string = "", showOutput: boolean = true) {
arduinoChannel.show();
const updatingIndex = packageName === "dummy" && !arch && !version;
if (updatingIndex) {
arduinoChannel.start(`Update package index files...`);
} else {
try {
const packagePath = path.join(this._settings.packagePath, "packages", packageName, arch);
if (util.directoryExistsSync(packagePath)) {
util.rmdirRecursivelySync(packagePath);
}
arduinoChannel.start(`Install package - ${packageName}...`);
} catch (error) {
arduinoChannel.start(`Install package - ${packageName} failed under directory : ${error.path}${os.EOL}
Please make sure the folder is not occupied by other procedures .`);
arduinoChannel.error(`Error message - ${error.message}${os.EOL}`);
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
return;
}
}
arduinoChannel.info(`${packageName}${arch && ":" + arch}${version && ":" + version}`);
try {
if (this.useArduinoCli()) {
await util.spawn(this._settings.commandPath,
["core", "install", `${packageName}${arch && ":" + arch}${version && "@" + version}`],
undefined,
{ channel: showOutput ? arduinoChannel.channel : null });
} else {
await util.spawn(this._settings.commandPath,
["--install-boards", `${packageName}${arch && ":" + arch}${version && ":" + version}`],
undefined,
{ channel: showOutput ? arduinoChannel.channel : null });
}
if (updatingIndex) {
arduinoChannel.end("Updated package index files.");
} else {
arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
}
} catch (error) {
// If a platform with the same version is already installed, nothing is installed and program exits with exit code 1
if (error.code === 1) {
if (updatingIndex) {
arduinoChannel.end("Updated package index files.");
} else {
arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
}
} else {
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
}
}
}