Skip to content

Add explicit path for dotenv#23

Merged
Nostromos merged 2 commits into
mainfrom
octokit-to-class
Apr 16, 2025
Merged

Add explicit path for dotenv#23
Nostromos merged 2 commits into
mainfrom
octokit-to-class

Conversation

@Nostromos
Copy link
Copy Markdown
Owner

Description

Due to issues with dotenv resolving a path to our .env file, considered turning most of githubClient.ts, including all of Octokit instantiation into a class to allow for easier passing around. This is most likely due to my own stupid misunderstanding of how node runs code.

This PR updates our start script and passes an explicit path to dotenv.

Note

I assumed this would be a bigger PR but it is not. I'm going through this motion to try out the Copilot code review.

Linked Issues

NA

Additional context

Code quality and cleanliness is poor. I will refactor this at some point but interested in what suggestions code reviewers will make.

@Nostromos Nostromos requested a review from Copilot April 16, 2025 15:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • package.json: Language not supported

Comment thread src/index.ts
} catch (error) {
console.error(`Failed to fetch user details for ${username}:`, error);
try {
const { data } = await octokit.rest.users.getAuthenticated();
Copy link

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage of top-level await requires that the module is run as an ES module or that the Node.js version supports top-level await. If this code may run in a CommonJS environment, consider wrapping it in an async function.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my prototyping workflow so I will kill this before I go live.

Comment thread src/api/githubClient.ts
Comment on lines +19 to 20
dotenv.config({ path: 'src/.env' });

Copy link

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using path.join or path.resolve (with __dirname) to construct the .env file path for OS-independent path resolution.

Suggested change
dotenv.config({ path: 'src/.env' });
dotenv.config({ path: path.resolve(__dirname, '../../.env') });

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. For now, I'll leave it as is but will create an issue for this to ensure I tackle it eventually.

@Nostromos Nostromos merged commit c19fe2d into main Apr 16, 2025
@Nostromos Nostromos deleted the octokit-to-class branch April 16, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants