Skip to content

Commit

Permalink
fix hb-servce update-node updater
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Nov 25, 2021
1 parent b2cb7a9 commit 66d94cf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ All notable changes to this project will be documented in this file. This projec

## NEXT

### Bug Fixes

* **System:** Added a fix to the [`hb-service update-node`](https://github.com/oznu/homebridge-config-ui-x/wiki/Homebridge-Service-Command#update-nodejs) command to prevent it breaking npm when uprading from Node 14 to 16

### Other Changes

* **i18n:** Improvements to Ukrainian language translations ([#1197](https://github.com/oznu/homebridge-config-ui-x/pull/1197))
* **i18n:** Improvements to Thai language translations ([#1200](https://github.com/oznu/homebridge-config-ui-x/pull/1200))
* **i18n:** Improvements to Traditional Chinese language translations ([#1240](https://github.com/oznu/homebridge-config-ui-x/pull/1240))
* **Plugins:** The following features have been added to assist plugin developers building [custom plugin user interfaces](https://github.com/homebridge/plugin-ui-utils):
* The "loading" spinner is now correctly shown on top of schema generated forms ([#1198](https://github.com/oznu/homebridge-config-ui-x/pull/1198))

Expand Down
18 changes: 18 additions & 0 deletions src/bin/hb-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,24 @@ export class HomebridgeServiceHelper {
}
}

/**
* Remove npm package
*/
public async removeNpmPackage(npmInstallPath: string) {
if (!await fs.pathExists(npmInstallPath)) {
return;
}

const spinner = ora(`Cleaning up npm at ${npmInstallPath}...`).start();

try {
await fs.remove(npmInstallPath);
spinner.succeed(`Cleaned up npm at at ${npmInstallPath}`);
} catch (e) {
spinner.fail(e.message);
}
}

/**
* Check the current status of the Homebridge UI by calling it's API
*/
Expand Down
3 changes: 3 additions & 0 deletions src/bin/platforms/darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ export class DarwinInstaller {
unlink: true,
};

// remove npm package as this can cause issues when overwritten by the node tarball
await this.hbService.removeNpmPackage(path.resolve(targetPath, 'lib', 'node_modules', 'npm'));

// extract
await this.hbService.extractNodejs(job.target, extractConfig);

Expand Down
3 changes: 3 additions & 0 deletions src/bin/platforms/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ export class LinuxInstaller {
unlink: true,
};

// remove npm package as this can cause issues when overwritten by the node tarball
await this.hbService.removeNpmPackage(path.resolve(targetPath, 'lib', 'node_modules', 'npm'));

// extract
await this.hbService.extractNodejs(job.target, extractConfig);

Expand Down

0 comments on commit 66d94cf

Please sign in to comment.