Timeline for How do I run 2 different functions from 1 file with 2 different command line prompts in Node.js?
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 13, 2024 at 5:14 | answer | added | Shivam Devidas Chapule | timeline score: 1 | |
Aug 13, 2024 at 4:30 | answer | added | Wyck | timeline score: 1 | |
Aug 13, 2024 at 4:30 | vote | accept | MeltingDog | ||
Aug 13, 2024 at 4:28 | comment | added | Jaromanda X | Just did it while you were commenting :D | |
Aug 13, 2024 at 4:28 | answer | added | Jaromanda X | timeline score: 2 | |
Aug 13, 2024 at 4:28 | comment | added | MeltingDog | Thanks. Want to make that an answer so I can accept? | |
Aug 13, 2024 at 4:20 | comment | added | Jaromanda X |
await ({ replace, revert })[process.argv.at(-1)]?.(); at the end of the file will do it
|
|
Aug 13, 2024 at 4:14 | comment | added | Jaromanda X |
you'll need to use process.argv to get the command line arguments, then some logic to call the appropriate function
|
|
Aug 13, 2024 at 4:07 | comment | added | MeltingDog | @JaromandaX ok, but how do I run those functions from the command line? | |
Aug 13, 2024 at 4:03 | comment | added | Jaromanda X |
no point exporting in that file, since nothing is importing it. you don't call your functions anywhere - you'll need to use process.argv to get the command line arguments, then some logic to call the appropriate function
|
|
Aug 13, 2024 at 3:58 | history | asked | MeltingDog | CC BY-SA 4.0 |