in src/arduino/arduino.ts [302:339]
public async installLibrary(libName: string, version: string = "", showOutput: boolean = true) {
arduinoChannel.show();
const updatingIndex = (libName === "dummy" && !version);
if (updatingIndex) {
arduinoChannel.start("Update library index files...");
} else {
arduinoChannel.start(`Install library - ${libName}`);
}
try {
if (this.useArduinoCli()) {
await util.spawn(this._settings.commandPath,
["lib", "install", `${libName}${version && "@" + version}`],
undefined,
{ channel: showOutput ? arduinoChannel.channel : undefined });
} else {
await util.spawn(this._settings.commandPath,
["--install-library", `${libName}${version && ":" + version}`],
undefined,
{ channel: showOutput ? arduinoChannel.channel : undefined });
}
if (updatingIndex) {
arduinoChannel.end("Updated library index files.");
} else {
arduinoChannel.end(`Installed library - ${libName}${os.EOL}`);
}
} catch (error) {
// If a library 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 library index files.");
} else {
arduinoChannel.end(`Installed library - ${libName}${os.EOL}`);
}
} else {
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
}
}
}