Skip to content

Commit

Permalink
unregister as needed before registering
Browse files Browse the repository at this point in the history
  • Loading branch information
playground committed Jan 27, 2023
1 parent 9c6235b commit 2d4577d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
19 changes: 17 additions & 2 deletions build/common/src/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/common/src/utils.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hzn-cli",
"version": "0.4.21",
"version": "0.4.22",
"description": "Open Horizon CLI toolkit helps streamline the process of preparing node agents and perform tasks between orgs environments",
"main": "./build/index.js",
"bin": {
Expand Down
19 changes: 17 additions & 2 deletions src/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1873,8 +1873,23 @@ export class Utils {
})
}
registerOnly() {
const arg = `hzn register`
return utils.shell(arg, `done registering this node`, `failed to register this node`)
return new Observable((observer) => {
this.unregisterAgent(true).subscribe({
complete: () => {
const arg = `hzn register`
utils.shell(arg, `done registering this node`, `failed to register this node`)
.subscribe({
complete: () => {
observer.next()
observer.complete()
},
error: (err) => observer.error(err)
})
}, error: (err) => {
observer.error(err);
}
})
})
}
registerWithPolicy(name: string, policy: string, auto = false) {
return new Observable((observer) => {
Expand Down

0 comments on commit 2d4577d

Please sign in to comment.