Obtaining images from a folder
The Files.js
file starts with the definition of the required modules:
var fs = require('fs'); var argv = require('optimist').argv; var readline = require('readline'); var glob = require('glob');
Immediately after, we need to define two variables. The currentDirectory
variable stores the path to the current working directory and rl
is an instance of the readline
module.
var currentDirectory = process.cwd() + '/'; var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
The createInterface
function accepts an object. The two required fields are input
and output
. The input
field will point to the incoming readable stream and output
to the writable stream. In our case, the user will type data directly into the terminal/console, so we will pass process.stdin
.
At the beginning of the chapter, we mentioned the optimist
module. We will use it to get the parameter from the command line. In our case, this will be the directory used to parse...