Skip to content

Commit

Permalink
Fix container spawning loop bug on windows (again).
Browse files Browse the repository at this point in the history
  • Loading branch information
agrojean-ledger committed Jul 31, 2023
1 parent af2f300 commit 85ddc60
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.4]

### Fixed

- Remove unfinished 'delete app from device' feature.

## [0.1.3]

### Fixed

- Fix infinite container spawning loop bug on Windows (for real this time).

## [0.1.2]

### Added
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Provide a quick and easy way to build and test applications for [Ledger](https://www.ledger.com/) devices.

The extension uses Ledger's own [docker image](https://github.com/LedgerHQ/ledger-app-builder/blob/master/dev-tools/Dockerfile) to allow developers to setup a build and test environement in a few minutes.
The extension uses Ledger's own [Alpine based Docker image](https://github.com/LedgerHQ/ledger-app-builder/blob/master/dev-tools/Dockerfile) to allow developers to setup a build and test environement in a few minutes.

* Build your app for all Ledger devices : Nano S, Nano S Plus, Nano X, Stax.
* Stay up to date with the latest SDK.
Expand Down Expand Up @@ -50,6 +50,14 @@ This extension contributes the following settings:

## Release Notes

## 0.1.4

* Remove unfinished 'delete app from device' feature.

## 0.1.3

* Fix infinite container spawning loop bug on Windows (for real this time).

## 0.1.2

* Better tooltips for sidebar items.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ledger-dev-tools",
"displayName": "ledger-dev-tools",
"description": "Tools to accelerate development of apps for Ledger devices.",
"version": "0.1.2",
"version": "0.1.4",
"publisher": "LedgerHQ",
"license": "Apache",
"icon": "resources/ledger-square.png",
Expand Down
9 changes: 4 additions & 5 deletions src/containerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ export class ContainerManager {
}

private checkContainerExists(containerName: string): boolean {
const command = `docker ps -a --filter "name=${containerName}" --format '{{.Names}}'`;
const command = `docker ps -a --filter "name=${containerName}" --format "{{.Names}}"`;
const execOptions: ExecSyncOptionsWithStringEncoding = { stdio: "pipe", encoding: "utf-8" };
const output = execSync(command, execOptions).toString();
const containers = output.split("\n").filter(Boolean);
console.log(`Docker containers ${containers}`);
return containers.includes(containerName);
return output.includes(containerName);
}

manageContainer(): void {
Expand All @@ -44,7 +42,7 @@ export class ContainerManager {
console.log(`Ledger: Container ${currentApp.containerName} not found, respawning it.`);
this.taskProvider.executeTaskByName("Update Container");
} else {
const command = `docker inspect -f '{{ .State.Status }}' ${containerName}`;
const command = `docker inspect -f "{{ .State.Status }}" ${containerName}`;
const containerStatus = execSync(command).toString().trim();
if (containerStatus === "running") {
this.statusBarManager.updateDevImageItem(DevImageStatus.running);
Expand All @@ -53,6 +51,7 @@ export class ContainerManager {
this.statusBarManager.updateDevImageItem(DevImageStatus.syncing);
this.treeProvider.updateContainerLabel(DevImageStatus.syncing);
} else {
console.log(`Ledger: Container ${currentApp.containerName} status is ${containerStatus}, respawning it.`);
this.statusBarManager.updateDevImageItem(DevImageStatus.stopped);
this.treeProvider.updateContainerLabel(DevImageStatus.stopped);
this.taskProvider.executeTaskByName("Update Container");
Expand Down

0 comments on commit 85ddc60

Please sign in to comment.