Skip to content

Commit f359843

Browse files
author
Akos Kitta
committed
Fixed the version ordering for libs.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 6448b44 commit f359843

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

arduino-ide-extension/src/common/protocol/boards-service.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export namespace Port {
130130
}
131131
if (isOSX) {
132132
// Example: `/dev/cu.usbmodem14401`
133-
if (/(tty|cu)\..*/.test(address.substring('/dev/'.length))) {
133+
if (/(tty|cu)\..*/.test(address.substring('/dev/'.length))) {
134134
return [
135135
'/dev/cu.MALS',
136136
'/dev/cu.SOC',
@@ -170,12 +170,6 @@ export interface BoardPackage extends ArduinoComponent {
170170
id: string;
171171
boards: Board[];
172172
}
173-
export namespace BoardPackage {
174-
/**
175-
* Most recent version comes first, then the previous versions. (`1.8.1`, `1.6.3`, `1.6.2`, `1.6.1` and so on.)
176-
*/
177-
export const VERSION_COMPARATOR = (left: string, right: string) => naturalCompare(right, left);
178-
}
179173

180174
export interface Board {
181175
name: string

arduino-ide-extension/src/common/protocol/installable.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const naturalCompare: (left: string, right: string) => number = require('string-natural-compare').caseInsensitive;
12
import { ArduinoComponent } from './arduino-component';
23

34
export interface Installable<T extends ArduinoComponent> {
@@ -8,4 +9,10 @@ export interface Installable<T extends ArduinoComponent> {
89
}
910
export namespace Installable {
1011
export type Version = string;
12+
export namespace Version {
13+
/**
14+
* Most recent version comes first, then the previous versions. (`1.8.1`, `1.6.3`, `1.6.2`, `1.6.1` and so on.)
15+
*/
16+
export const COMPARATOR = (left: Version, right: Version) => naturalCompare(right, left);
17+
}
1118
}

arduino-ide-extension/src/node/boards-service-impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class BoardsServiceImpl implements BoardsService {
244244
const pkg = packages.get(id);
245245
if (pkg) {
246246
pkg.availableVersions.push(platform.getLatest());
247-
pkg.availableVersions.sort(BoardPackage.VERSION_COMPARATOR);
247+
pkg.availableVersions.sort(Installable.Version.COMPARATOR);
248248
} else {
249249
packages.set(id, toPackage(platform));
250250
}

arduino-ide-extension/src/node/library-service-impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class LibraryServiceImpl implements LibraryService {
4747
.slice(0, 50)
4848
.map(item => {
4949
// TODO: This seems to contain only the latest item instead of all of the items.
50-
const availableVersions = item.getReleasesMap().getEntryList().map(([key, _]) => key);
50+
const availableVersions = item.getReleasesMap().getEntryList().map(([key, _]) => key).sort(Installable.Version.COMPARATOR);
5151
let installedVersion: string | undefined;
5252
const installed = installedLibsIdx.get(item.getName());
5353
if (installed) {

0 commit comments

Comments
 (0)