function writeFiles(files) {
  let written = 0;

  for (const file of Object.values(files)) {
    if (!isObject(file)) {
      continue;
    }

    if (file.constructor === File) {
      fs.mkdirSync(path.dirname(file.path), { recursive: true });
      fs.writeFileSync(file.path, file.contents);
      ++written;
    } else {
      written += writeFiles(file);
    }
  }

  return written;
}
Recursively write files to disc

@param {object} files Files
@returns {number}     Number of written files