Bab

Why did I develop this? What were my goals?

Bab searches multiple text files for specific text often and I like to have the output in a certain format and I also don't like having to type out what directories to exclude all the time eg .git and node_modules. Bab is similar to Grep but with the option of saving your settings in different profiles and you can also configure it to output the information in different formats. I wanted more features than grep provides. Even though grep is good, I wanted to do this search utility because it's more specific to the way I like search results to appear. It has the file list at the top and I can customize it to have certain files and directories excluded.

I wanted to do a project that uses path, fs and file processing with asynchronous programming.

What tech stack was used?

Javascript

Node

DOS

What did I learn?

Reading files in streams is more efficient for a larger number of files. It reads files in smaller chunks. fs.createReadStream() does this.

String.raw``

String.raw is really good for paths and regular expressions.

It avoids putting escapes in to a string just to feed a new RegExp(). RexExp Is messy with paths eg E:\\dir1\\Sub-dir1

Instead:

let str1 = String.raw`E:\dir1\Sub-dir1`

Linux, Perl and Javascript are all very similar with regular expressions.

map() runs all the Promises asynchronously. The fastest/shortest one finishes first, not synchronously/sequentially.

for() await - This runs the Promises synchronosouly/sequentially.

Bab took time to develop. It maybe wasn't the best use of my time. Although it has good features, grep, awk and sed and other Linux commands are battle tested and can almost do the same for what it's worth.

If you do OS stuff in Node, Linux can probably do it already. For this app, there is grep, awk, sed and other commands then a lot of 3rd party things for Linux so it's better to rely on that.

To use bab, you need to have Node installed and you then need to configure the operating system to run it with Node. Something that users will probably see as not worth it. It's a hurdle.

Also, Rust or C would be a better language to develop a tool like this with.

But it works on both Linux and WIndows because it's Node.

CLI is better than GUI for things like text search.

For the settings file, I chose .js instead of .json it let you leave comments, JSON files don't.

Windows has more restrictions on filename than Linux does. Linux accepts most characters in a filename, windows has restrictions.

What challenges did I face? And how did I overcome them?

I had to start using text streams because it was much faster so I had to re-write parts of the code.