Skip to content

Commit

Permalink
fix(*): load package data relatively to module dir (#445)
Browse files Browse the repository at this point in the history
relates-to: #442
  • Loading branch information
lsndr authored Aug 24, 2023
1 parent ab9efa4 commit 95d6ec4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Config/CliInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export class CliInfo {
public readonly version: string;
public readonly distribution: string | undefined;

constructor(cwd: string = process.cwd()) {
constructor(cwd: string) {
const packagePath = this.getPackagePath(cwd);
const packageData = this.getPackageData(packagePath);

this.cwd = packagePath ? path.dirname(packagePath) : cwd;
this.version = process.env.VERSION ?? packageData?.version;
this.distribution = packageData.brightCli?.distribution;
this.distribution = packageData?.brightCli?.distribution;
}

private getPackageData(packagePath: string) {
Expand Down
4 changes: 3 additions & 1 deletion src/Config/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ container
.register('tsyringe', {
useValue: container
})
.register<CliInfo>(CliInfo, { useValue: new CliInfo(process.cwd()) })
.register<CliInfo>(CliInfo, {
useValue: new CliInfo(__dirname)
})
.register(
RequestExecutor,
{
Expand Down

0 comments on commit 95d6ec4

Please sign in to comment.