nelreina
9/7/2017 - 8:17 AM

nodejs writefile promisify

import fs from 'fs';

const writeFile = (fileName, content) =>
  new Promise((resolve, reject) => {
    fs.writeFile(fileName, content, err => {
      if (err) reject(err);
      resolve(`${fileName} created!`);
    });
  });