Update index.js

Fix for Error: EEXIST, mkdir for subfolders - directories are treated as files.