The node fs package has the following methods to list a directory:
fs.readdir(path, [callback]) Asynchronous readdir(3). Reads the contents of a directory. The callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.
fs.readdirSync(path) Synchronous readdir(3). Returns an array of filenames excluding '.' and '..
But how do I get a list of files matching a file specification, for example *.txt?