react-universally
Version:
A starter kit for universal react applications.
42 lines (35 loc) • 1 kB
JavaScript
import HappyPack from 'happypack';
import notifier from 'node-notifier';
import colors from 'colors/safe';
import { execSync } from 'child_process';
import appRootDir from 'app-root-dir';
// Generates a HappyPack plugin.
// @see https://github.com/amireh/happypack/
export function happyPackPlugin({ name, loaders }) {
return new HappyPack({
id: name,
verbose: false,
threads: 4,
loaders,
});
}
export function log(options) {
const title = `${options.title.toUpperCase()}`;
if (options.notify) {
notifier.notify({
title,
message: options.message,
});
}
const level = options.level || 'info';
const msg = `==> ${title} -> ${options.message}`;
switch (level) {
case 'warn': console.log(colors.yellow(msg)); break;
case 'error': console.log(colors.bgRed.white(msg)); break;
case 'info':
default: console.log(colors.green(msg));
}
}
export function exec(command) {
execSync(command, { stdio: 'inherit', cwd: appRootDir.get() });
}