Skip to content

Commit

Permalink
Merge pull request #431 from Garfonso/main
Browse files Browse the repository at this point in the history
fix dev-server update with .tgz files
  • Loading branch information
Apollon77 authored Nov 9, 2023
2 parents cb731cc + b771e5d commit 113eca0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
17 changes: 12 additions & 5 deletions dist/index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,16 @@ class DevServer {
.join('\n')}\n\nto use dev-server.`);
}
async update() {
var _a;
await this.checkSetup();
this.log.notice('Updating everything...');
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.useSymlinks)) {
this.log.notice('Building local adapter.');
await this.buildLocalAdapter();
await this.installLocalAdapter(false); //do not install, keep .tgz file.
}
this.execSync('npm update --loglevel error', this.profileDir);
this.uploadAdapter('admin');
await this.buildLocalAdapter();
await this.installLocalAdapter();
if (!this.isJSController())
this.uploadAdapter(this.adapterName);
Expand Down Expand Up @@ -1288,7 +1293,7 @@ class DevServer {
this.execSync('npm run build', this.rootDir);
}
}
async installLocalAdapter() {
async installLocalAdapter(doInstall = true) {
var _a, _b;
this.log.notice(`Install local iobroker.${this.adapterName}`);
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.useSymlinks) {
Expand All @@ -1306,9 +1311,11 @@ class DevServer {
const { stdout } = await this.getExecOutput('npm pack', this.rootDir);
const filename = stdout.trim();
this.log.info(`Packed to ${filename}`);
const fullPath = path.join(this.rootDir, filename);
this.execSync(`npm install "${fullPath}"`, this.profileDir);
await this.rimraf(fullPath);
if (doInstall) {
const fullPath = path.join(this.rootDir, filename);
this.execSync(`npm install "${fullPath}"`, this.profileDir);
await this.rimraf(fullPath);
}
}
}
async installRepoAdapter(adapterName) {
Expand Down
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,14 @@ class DevServer {
await this.checkSetup();
this.log.notice('Updating everything...');

if (!this.config?.useSymlinks) {
this.log.notice('Building local adapter.');
await this.buildLocalAdapter();
await this.installLocalAdapter(false); //do not install, keep .tgz file.
}
this.execSync('npm update --loglevel error', this.profileDir);
this.uploadAdapter('admin');

await this.buildLocalAdapter();
await this.installLocalAdapter();
if (!this.isJSController()) this.uploadAdapter(this.adapterName);

Expand Down Expand Up @@ -1506,7 +1510,7 @@ class DevServer {
}
}

private async installLocalAdapter(): Promise<void> {
private async installLocalAdapter(doInstall = true): Promise<void> {
this.log.notice(`Install local iobroker.${this.adapterName}`);

if (this.config?.useSymlinks) {
Expand All @@ -1523,9 +1527,11 @@ class DevServer {
const { stdout } = await this.getExecOutput('npm pack', this.rootDir);
const filename = stdout.trim();
this.log.info(`Packed to ${filename}`);
const fullPath = path.join(this.rootDir, filename);
this.execSync(`npm install "${fullPath}"`, this.profileDir);
await this.rimraf(fullPath);
if (doInstall) {
const fullPath = path.join(this.rootDir, filename);
this.execSync(`npm install "${fullPath}"`, this.profileDir);
await this.rimraf(fullPath);
}
}
}

Expand Down

0 comments on commit 113eca0

Please sign in to comment.