Skip to content

Commit

Permalink
chore: relax sidecar production version check
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Nov 5, 2024
1 parent 8564fce commit c0ce714
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/sidecar/Sidecar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Sidecar extends BaseClient<
public static readonly symbol = 'Boltz';
public static readonly serviceName = 'sidecar';

private static readonly dirtySuffix = '-dirty';
private static readonly isProduction = process.env.NODE_ENV === 'production';

private static childProcess?: child_process.ChildProcessWithoutNullStreams;
Expand Down Expand Up @@ -168,7 +169,8 @@ class Sidecar extends BaseClient<
const ourVersion = getVersion();

const versionCompatible = Sidecar.isProduction
? info.version === ourVersion
? Sidecar.trimDirtySuffix(info.version) ===
Sidecar.trimDirtySuffix(ourVersion)
: info.version.split('-')[0] === ourVersion.split('-')[0];

if (!versionCompatible) {
Expand Down Expand Up @@ -504,6 +506,11 @@ class Sidecar extends BaseClient<
toObject,
);
};

private static trimDirtySuffix = (version: string): string =>
version.endsWith(Sidecar.dirtySuffix)
? version.slice(0, -Sidecar.dirtySuffix.length)
: version;
}

export default Sidecar;
Expand Down
8 changes: 8 additions & 0 deletions test/unit/sidecar/Sidecar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ describe('Sidecar', () => {
);
});
});

describe('trimDirtySuffix', () => {
test('should trim dirty suffix', () => {
const version = '3.8.0-1ec2944b';

expect(Sidecar['trimDirtySuffix'](`${version}-dirty`)).toEqual(version);
});
});
});

0 comments on commit c0ce714

Please sign in to comment.