Skip to content

Commit

Permalink
server: output investigation commands for getAppProfile/getBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Sep 1, 2016
1 parent 4cce3da commit 6eef3c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions lib/server/modules/ws/getAppProfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var path = require('path');
var url = require('url');
var fs = require('fs');
var resolve = require('resolve');
var chalk = require('chalk');
var utils = require('../utils');
var logMsg = utils.logMsg;
var logWarn = utils.logWarn;
var logError = utils.logError;

function resolveFilename(filename){
if (!fs.existsSync(filename))
Expand All @@ -30,7 +31,7 @@ module.exports = function(options){

if (typeof callback != 'function')
{
logWarn('socket', chalk.yellow('getAppProfile') + ' callback not a function');
logError('socket', chalk.yellow('getAppProfile') + ' callback not a function');
return;
}

Expand All @@ -48,7 +49,7 @@ module.exports = function(options){

if (!indexFilename)
{
logWarn('socket', chalk.yellow('getAppProfile') + ' file is not resolved (' + filepath + ')');
logError('socket', chalk.yellow('getAppProfile') + ' file is not resolved (' + filepath + ')');
callback('getAppProfile: file is not resolved (' + filepath + ')');
return;
}
Expand All @@ -62,7 +63,11 @@ module.exports = function(options){
.on('exit', function(code){
if (code)
{
logWarn('socket', chalk.yellow('getAppProfile') + ' exit ' + code);
logError('socket', chalk.yellow('getAppProfile') + ' Exit code ' + code);
logError('socket', chalk.yellow('getAppProfile') + ' Command for issue investigation:\n> ' +
'node ' + path.resolve(resolve.sync('basisjs-tools-build'), '../../bin/extract') + ' ' +
args.concat('--no-config', '--target', 'log').join(' ')
);
callback('Process exit with code ' + code);
}
else
Expand All @@ -73,7 +78,7 @@ module.exports = function(options){
.on('message', function(res){
if (res.error)
{
logWarn('socket', chalk.yellow('getAppProfile') + ' error: ' + res.error);
logError('socket', chalk.yellow('getAppProfile') + ' ' + res.error);
callback('Error on app profile fetch: ' + res.error);
}
else
Expand Down
15 changes: 10 additions & 5 deletions lib/server/modules/ws/getBundle.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var path = require('path');
var url = require('url');
var fs = require('fs');
var resolve = require('resolve');
var chalk = require('chalk');
var utils = require('../utils');
var files = require('../files');
var logMsg = utils.logMsg;
var logWarn = utils.logWarn;
var logError = utils.logError;

function resolveFilename(filename){
if (!fs.existsSync(filename))
Expand Down Expand Up @@ -33,7 +34,7 @@ module.exports = function(options){

if (typeof callback != 'function')
{
logWarn('socket', chalk.yellow('getBundle') + ' callback not a function');
logError('socket', chalk.yellow('getBundle') + ' callback not a function');
return;
}

Expand Down Expand Up @@ -68,7 +69,7 @@ module.exports = function(options){

if (!indexFilename)
{
logWarn('socket', chalk.yellow('getBundle') + ' file is not resolved (' + filepath + ')');
logError('socket', chalk.yellow('getBundle') + ' file is not resolved (' + filepath + ')');
callback('getBundle: file is not resolved (' + filepath + ')');
return;
}
Expand All @@ -82,7 +83,11 @@ module.exports = function(options){
.on('exit', function(code){
if (code)
{
logWarn('socket', chalk.yellow('getBundle') + ' exit ' + code);
logError('socket', chalk.yellow('getBundle') + ' Exit code ' + code);
logError('socket', chalk.yellow('getBundle') + ' Command for issue investigation:\n> ' +
'node ' + path.resolve(resolve.sync('basisjs-tools-build'), '../../bin/build') + ' ' +
args.concat('--no-config', '--verbose').join(' ')
);
callback('Process exit with code ' + code);
}
else
Expand All @@ -93,7 +98,7 @@ module.exports = function(options){
.on('message', function(res){
if (res.error)
{
logWarn('socket', chalk.yellow('getBundle') + ' error: ' + res.error);
logError('socket', chalk.yellow('getBundle') + ' ' + res.error);
callback('Error on build: ' + res.error);
}
else if (res.event === 'done')
Expand Down

0 comments on commit 6eef3c7

Please sign in to comment.