code: function openStream(filename) {
    return new Promise((resolve, reject) => {
      const stream = fs.createWriteStream(filename, { flags: 'a' });
  
      const cleanup = () => {
        /* eslint-disable */
        stream.removeListener('error', onError);
        stream.removeListener('open', onOpen);
        /* eslint-enable */
      };
  
      const onError = (err) => {
        try {
          stream.close();
        } catch (e) {
          ;
        }
        cleanup();
        reject(err);
      };
  
      const onOpen = () => {
        cleanup();
        resolve(stream);
      };
  
      stream.once('error', onError);
      stream.once('open', onOpen);
    });
  }
docs: /*
  Helpers