nodeJS, fs, path - creating new directorties
There are util libraries for this:fs-extra. 

From its doc:


  mkdirs(dir, callback) Creates a directory. If the parent hierarchy
  doesn't exist, it's created. Like mkdir -p.
  
  Alias: mkdirp()
  
  Sync: mkdirsSync() / mkdirpSync()
  
  Examples:

var fs = require('fs-extra')

fs.mkdirs('/tmp/some/long/path/that/prob/doesnt/exist', function (err) {
  if (err) return console.error(err)
  console.log("success!")
})

fs.mkdirsSync('/tmp/another/path')



If you write function as a promise it would enable other code to run between each step of your function (eg. between each subdir being created) so it will not block other code like sending some request after calling this function.