code: function getDirectoryUidIfCannotModify(dir) {
      return new Promise((fulfill, reject) => {
          fs.stat(dir, (err, stats) => {
              if (err) {
                  return reject(err);
              }
              if (!stats.isDirectory()) {
                  return reject(new Error('Not a directory'));
              }
              fs.access(dir, fs.constants.W_OK, err => {
                  if (err) {
                      // user can't write to this directory
                      fulfill(stats.uid);
                      return;
                  }
                  fulfill(null); // user can write to this directory
              });
          })
      });
  }
docs: Check if the current process can modify the directory
  (i.e. rename files in it). Returns promise resolving
  to uid of the directory if it CANNOT modify, otherwise
  resolving to null.
  
  Rejects if stat call on the directory fails or the
  path is not a directory.
  
  @param {string} dir path to directory
  @returns {Promise<number | null>}