underctrl-io / commandkit

Only focus on what matters - Let CommandKit handle your commands and events in your Discord.js projects!
https://commandkit.js.org
MIT License
86 stars 12 forks source link

Use current working directory for paths #20

Closed NotM1Dev closed 10 months ago

NotM1Dev commented 10 months ago

I used path.resolve with the current working directory and the constructor options. This is easier for ESM projects, since you don't have to declare a dirname variable and can just type ./src/commands for example.

I've also used Prettier to format a _meta.json file, so new documentation pages can be added successfully.

netlify[bot] commented 10 months ago

Deploy Preview for commandkit ready!

Name Link
Latest commit 423411cfa68fb4a053221c2fdef5033e63ad94b1
Latest deploy log https://app.netlify.com/sites/commandkit/deploys/65389c809ba9b70008c6c1e5
Deploy Preview https://deploy-preview-20--commandkit.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

NotM1Dev commented 10 months ago

Apologies for the delay. Got exams this week 😭

I'll have to test the resolving of paths with this approach next week since I don't want it to introduce breaking changes.

It's fine. I know about your exams. This probably won't introduce anything breaking because path.resolve would still work when dirname is provided.

notunderctrl commented 10 months ago

It's fine. I know about your exams. This probably won't introduce anything breaking because path.resolve would still work when dirname is provided.

Even when appended with the current working directory?

NotM1Dev commented 10 months ago

Even when appended with the current working directory?

@notunderctrl Yeah, path.resolve is pretty good at this. Here's how I tested it:

const path = require('path');
const getPath = (p) => path.resolve(process.cwd(), p);

console.log(getPath('./src')); // Full path
console.log(getPath(`${__dirname}/src`)); // Full path