Use winston

This commit is contained in:
Ibby Hadeed
2017-12-28 23:15:34 -05:00
parent a26457b30a
commit 1c35991548
8 changed files with 88 additions and 14 deletions
+9 -3
View File
@@ -5,6 +5,7 @@ import * as uglifyJsPlugin from 'uglifyjs-webpack-plugin';
import * as unminifiedPlugin from 'unminified-webpack-plugin';
import { cleanEmittedData, EMIT_PATH, InjectableClassEntry } from '../build/transformers/extract-injectables';
import { ROOT } from '../build/helpers';
import { Logger } from '../logger';
const DIST = path.resolve(ROOT, 'dist');
const INDEX_PATH = path.resolve(DIST, 'index.js');
@@ -45,7 +46,7 @@ const webpackConfig: webpack.Configuration = {
new uglifyJsPlugin({
sourceMap: true
}),
new unminifiedPlugin()
]
};
@@ -66,9 +67,14 @@ function createIndexFile() {
}
function compile() {
Logger.profile('build-es5');
webpack(webpackConfig, (err, stats) => {
if (err) console.log(err);
else console.log(stats);
Logger.profile('build-es5');
if (err) Logger.error('Error occurred while compiling with Webpack', err);
else {
Logger.info('Compiled ES5 file with Webpack successfully.');
// Logger.verbose('Webpack complete', stats, () => {});
}
cleanEmittedData();
});
}
+9 -5
View File
@@ -5,6 +5,7 @@ import { exec } from 'child_process';
import { PLUGIN_PATHS, ROOT } from '../build/helpers';
import { cpus } from 'os';
import * as Queue from 'async-promise-queue';
import { Logger } from '../logger';
const MAIN_PACKAGE_JSON = require('../../package.json');
const VERSION = MAIN_PACKAGE_JSON.version;
@@ -66,18 +67,19 @@ function prepare() {
}
async function publish(ignoreErrors: boolean = false) {
Logger.profile('Publishing');
// upload 1 package per CPU thread at a time
const worker = Queue.async.asyncify((pkg: any) => {
new Promise<any>((resolve, reject) => {
exec(`npm publish ${ pkg } ${ FLAGS }`, (err, stdout) => {
if (stdout) {
console.log(stdout);
Logger.log(stdout.trim());
resolve(stdout);
}
if (err) {
if (!ignoreErrors) {
if (err.message.includes('You cannot publish over the previously published version')) {
console.log('Ignoring duplicate version error.');
Logger.verbose('Ignoring duplicate version error.');
return resolve();
}
reject(err);
@@ -89,10 +91,12 @@ async function publish(ignoreErrors: boolean = false) {
try {
await Queue(worker, PACKAGES, cpus().length);
console.log('Done publishing!');
Logger.log('Done publishing!');
} catch (e) {
console.log('Error publishing!');
console.log(e);
Logger.error('Error publishing!');
Logger.error(e);
} finally {
Logger.profile('Publishing');
}
}