Video Pending

Created by Zed A. Shaw Updated 2024-02-15 03:22:43
 

03: Replicate ls

This starts you off with a simple command line parsing library and a globbing library to get going named fast-glob. "Globbing" is what you're doing when you use regular expression patterns to match files like this:

ls *.txt

The fast-glob library is a good library with only one quirk to watch out for: It will not convert \ (backslash) characters to / in your glob. That means if you use C:\Users\zed\*.txt it will fail. You'll have to convert all \ to / on Windows.

File Attributes

Part of the ls command is printing out the attributes of a file. For that you'll need fs.stat found in the fs module.

Previous Lesson Next Lesson

Register for Learn JavaScript the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.