Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Here's my solution to the challenge. I now have a flight repl, I can create flight objects, and they're automatically displayed in my console. I can also use the triggerArrive and triggerDepart functions. So let's take a look at how I did this. In index.js, I'm starting out with a hash bang, this command locates Node for us, so that we can run our script. Next, I require the repl module, and I also require the local flight module that we've been working with. Then, I create a prompt, based off the repl module.
Finally, I assign the flight function into the context of the prompt. Let's also take a look at package.json. I named this project flight, so that flight is the name of the command that I type. Then I also added index.js as the property for bin. When all of this was in place, I went to terminal, and I went to the path of the project. Then I used npm link to install the command. I'm going to start the command back up again. There's one pit fall that you want to avoid when you're creating objects with this flight module.
If I just call flight and don't pass an argument in, it's going to give an error. This function is expecting exactly one argument, so even if you pass in a blank object, it'll still work. So that's how you can create a repl, and make it available as a Command Line tool.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98399 Viewers
61 Video lessons · 85685 Viewers
71 Video lessons · 69614 Viewers
56 Video lessons · 101939 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.