Use some promises to prevent race conditions when writing manifest files.