microbundle/src/utils.js
Ward Peeters 0eadcd9bce feat(babel): merges babelrc with microbunde babel config (#396)
* feat(babel): merges babelrc with microbunde babel config

* update tests

* Fix README.md

Fix examples description

* remove unused rollup-plugin-flow dependency (#379)
2019-05-29 00:46:59 +02:00

25 lines
677 B
JavaScript

import fs from 'fs';
import { promisify } from 'es6-promisify';
export const readFile = promisify(fs.readFile);
// export const writeFile = promisify(fs.writeFile);
export const stat = promisify(fs.stat);
export const isDir = name =>
stat(name)
.then(stats => stats.isDirectory())
.catch(() => false);
export const isFile = name =>
stat(name)
.then(stats => stats.isFile())
.catch(() => false);
export const stdout = console.log.bind(console); // eslint-disable-line no-console
export const stderr = console.error.bind(console);
export const isTruthy = obj => {
if (!obj) {
return false;
}
return obj.constructor !== Object || Object.keys(obj).length > 0;
};