July 2017
Intermediate to advanced
300 pages
5h 43m
English
Other file managers usually accept command-line options. For example, you can specify a folder when launching Windows Explorer. It also responds to various switches. Let's say that you can give it switch /e, and Explorer will open the folder in expanded mode.
NW.js reveals command-line options as an array of strings in nw.App.argv. So, we can change the code of the DirService initialization in the main module:
./js/app.js
const dirService = new DirService( nw.App.argv[ 0 ] );
Now, we can open a specified folder in the File Explorer straight from the command line:
npm start ~/Sandbox
In UNIX-based systems, the tilde means user home directory. The equivalent in Windows will be as follows:
npm start %USERPROFILE%Sandbox ...
Read now
Unlock full access