Ask coding questions

← Back to all posts
CLI
darkdarcool (130)

Hi there!

I have been making a module for a while where it worked, and it was nice.

But since it's similar to jest, I want one more thing to be like it

When you run npx jest in the terminal, it gives you all your test, but I want mine to be:

npx chitchatjs myfile

So you don't have to require it

I got the executable part down, but I have no idea how to make it so chitchat can find a file, and make it so you don't have require it.

Can someone fork my project and show me how to do it? It would be great!

Answered by Coder100 (18099) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18099)

what do you mean so you don't have to require it?

Coder100 (18099)

wait a second
how about something like this:

let file = fs.readFileSync(...);
file = `const test = require("chitchatjs");\n` + file

right, that's what you want?

@darkdarcool

darkdarcool (130)

@Coder100
plus I don't parse files, this is still just a module

Coder100 (18099)

@darkdarcool but still please explain what you mean by not having to require it not having to require anything sounds like a recipe for disaster to me... you don't know what the function comes from, and it is a good reminder to export your library!!

darkdarcool (130)

@Coder100 lemme inv you to the repl and we can talk there

darkdarcool (130)

@Coder100
There I can tell you more of what I want

darkdarcool (130)

@Coder100
I fixed it! I'll mark you as correct!

darkdarcool (130)

@Coder100
Changed name, and made replace stuff better!

darkdarcool (130)

@Coder100
Since I can make flags, and found out how to execute bash, I have so many ideas !