示例#1
0
              function(err, res) {
                if (err) return cb(err);

                if (runMigrations) {
                  if (target.migrateTask) {
                    shipit.log(chalk.bgRed('You should run task `migrate`!'));
                  } else {
                    shipit.log(chalk.bgRed('You should run the migrations!'));
                  }
                }

                if (runEditConfig) shipit.log(chalk.bgRed('You should edit the config file!'));
                if (runReindex) shipit.log(chalk.bgRed('You should rebuild Sphinx indexes'));
                if (runFXMigrations) shipit.log(chalk.bgRed('You should run task `migrate_flexible`!'));

                inquirer.prompt([{
                  type: 'confirm',
                  message: 'Do you want to update the ' + chalk.yellow(targetName) + ' ?',
                  name: 'confirm'
                }], function(ans) {
                  if (!ans.confirm) {
                    shipit.log('task was stopped by user');
                    return taskCallback();
                  }
                  return cb(null);
                });
              });
示例#2
0
util.logEnv = function() {
    var project = require('../../package.json');

    var msg = [
        chalk.bold(project.name),
        chalk.inverse(ENV)
    ];

    if(util.isWatching) {
        msg.push(chalk.bgMagenta('WATCHING'));
    }
    if(util.isParallel) {
        msg.push(chalk.bgBlue('PARALLEL BUILD'));
    }
    if(util.isSmart) {
        msg.push(chalk.bgBlue('SMART BUILD'));
    }
    if(util.isSpeedy) {
        msg.push(chalk.bgRed('SPEEDY BUILD'));
    }
    if(util.ignoreErrors) {
        msg.push(chalk.bgRed('IGNORE ERRORS'));
    }

    util.log(msg.join(' | '));
};
示例#3
0
 return new Promise((resolve) => {
   const line1 =
     `${chalk.bgRed('ERROR')} ${chalk.red(' - ', 'This is a', chalk.green('junk'), 'command')}`;
   const line2 = `${chalk.bgRed('ERROR')}${chalk.red(' - ', 'I throw an error message')}`;
   const out   = `${line1}\n${line2}`;
   resolve(out);
 });
示例#4
0
exports.info = function(req, res, next){
  var debug = process.env.DEBUG * 1;

  if(debug){
    console.log(chalk.bgRed('--------------------------------------------------------------------------------'));
    console.log(chalk.bold.red('TIME   :'), chalk.bold.blue(new Date()));
    console.log(chalk.bold.red('PORT   :'), process.env.PORT);
    console.log(chalk.bold.red('DB     :'), process.env.DB);
    console.log(chalk.bold.red('URL    :'), req.url);
    console.log(chalk.bold.red('VERB   :'), req.method);
    console.log(chalk.bold.green('PARAMS :'), req.params);
    console.log(chalk.bold.green('QUERY  :'), req.query);
    console.log(chalk.bold.green('BODY   :'), req.body);
    console.log(chalk.bold.green('LOCALS :'), res.locals);
    console.log(chalk.bold.green('SESSION:'), req.session);
    console.log(chalk.bold.red('SESSID :'), req.sessionID);

    if(debug === 2){
      console.log(chalk.bgBlue('--------------------------------------------------------------------------------'));
      console.log(chalk.bold.red('HEADERS:'), req.headers);
      console.log(chalk.bgBlue('--------------------------------------------------------------------------------'));
      console.log(chalk.bold.red('ENV    :'), process.env);
    }

    console.log(chalk.bgRed('--------------------------------------------------------------------------------'));
  }

  next();
};
示例#5
0
  highlightDifferences(a, b) {
    let differ;
    if (a.match(LINEBREAK_REGEX) || b.match(LINEBREAK_REGEX)) {
      // `diff` uses the Myers LCS diff algorithm which runs in O(n+d^2) time
      // (where "d" is the edit distance) and can get very slow for large edit
      // distances. Mitigate the cost by switching to a lower-resolution diff
      // whenever linebreaks are involved.
      differ = diff.diffLines;} else 
    {
      differ = diff.diffChars;}

    const changes = differ(a, b);
    const ret = { a: '', b: '' };
    for (let i = 0, il = changes.length; i < il; i++) {
      const change = changes[i];
      if (change.added) {
        ret.b += chalk.bgRed(change.value);} else 
      if (change.removed) {
        ret.a += chalk.bgRed(change.value);} else 
      {
        ret.a += change.value;
        ret.b += change.value;}}


    return ret;}
              Company.findById(linker.company, function ( err, company ) {
                if( err ) {
                  winston.log('error', chalk.bgRed(err));
                  throw new Error(err);
                }

                if( !company ) {

                  winston.log('error', chalk.bgRed('No Company found for', rate.legacyCompanyNumber, 'Skipping...'));

                  fulfilled++;
                  rates.push( rateRecord );

                  if( hashLen === fulfilled ) {
                    return callback( rates );
                  }

                } else {

                  if( _.isArray( company.medicalRates ) ) {
                    if( indexOfId( company.medicalRates, rateRecord._id ) < 0 ) {
                      // Create Rate in Company record
                      company.medicalRates.push( rateRecord._id );
                    }
                  } else {
                    winston.log('info', chalk.bgYellow('Found company w/o medicalRate array'));
                    company.medicalRates = [];
                    company.medicalRates.push( rateRecord._id );
                  } // if( _.isArray...

                  company.save(function ( err, companyRecord ) {
                    if( err ) {
                      winston.log('error', chalk.bgRed(err));
                      throw new Error(err);
                    }

                    winston.info(chalk.dim(fulfilled, '/', hashLen, '-', 'Saved company', companyRecord.name.company));

                    rateRecord.company = companyRecord._id;

                    rateRecord.save(function ( err, finalRecord ) {
                      if( err ) {
                        winston.log('error', chalk.bgRed(err));
                        throw new Error(err);
                      }

                      fulfilled++;
                      rates.push( finalRecord );

                      if( hashLen === fulfilled ) {
                        console.log( finalRecord );
                        callback( rates );
                      }
                    }); // rateRecord.save
                  }); // company.save
                } // if( !company )      
              }); // Company.findOne
示例#7
0
function checkDeps (target) {
  try {
    if (typeof target === 'undefined' || target === null) {
      console.log(chalk.bgRed('time-using-middleware does depends on cookie-parser middleware as it need to parse cookie and check it. Please check your deps.'))
    }
  } catch (e) {
    console.log(chalk.bgRed('Error'))
  }
}
示例#8
0
文件: init.js 项目: 178518/antd-tools
function reportNoConfig() {
  console.log(
    chalk.bgRed('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'));
  console.log(
    chalk.bgRed('!! Unable to setup antd-tools: project\'s package.json either missing !!'));
  console.log(
    chalk.bgRed('!! or malformed. Run `npm init` and then reinstall antd-tools.       !!'));
  console.log(
    chalk.bgRed('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'));
}
示例#9
0
文件: in.js 项目: tocausan/Renmin
                    UserPassword.findOne({user: user._id}, 'password', function (err, password) {
                        switch (true) {

                            case(user.confirmed != true):
                                // user not confirmed
                                console.log(chalk.bgRed(msg[2]));

                                res.format({
                                    html: function () {
                                        res.redirect('?error=' + msg[2]);
                                    },
                                    json: function(){
                                        res.json({
                                            error: msg[2]
                                        });
                                    }
                                });
                            break;

                            case(password != null && passwordHash.verify(req.body.password, password.password)):
                                // password exist and correct
                                console.log(chalk.bgGreen(msg[3]));
                                console.log(chalk.bgGreen(msg[5]));

                                // set session
                                req.session.auth = user;

                                res.format({
                                    html: function () {
                                        res.redirect("/"+ req.query.redirect);
                                    },
                                    json: function(){
                                        res.json({success: msg[5]})
                                    }
                                });
                                break;

                            default :
                                // password not found or incorrect
                                console.log(chalk.bgRed(msg[6]));

                                res.format({
                                    html: function () {
                                        res.redirect('?error=' + msg[6]);
                                    },
                                    json: function(){
                                        res.json({
                                            error: msg[6]
                                        });
                                    }
                                });
                                break;
                        }
                    });
示例#10
0
function printHello() {
  console.log('\n');
  console.log('  ' + chalk.bgBlue('     ') + chalk.bgCyan('                   ') + chalk.bgGreen('     '));
  console.log('  ' + chalk.bgBlue('     ') + chalk.bgCyan('                   ') + chalk.bgGreen('     '));
  console.log('  ' + chalk.bgBlue('     ') + chalk.bold.black.bgWhite('                   ') + chalk.bgYellow('     '));
  console.log('  ' + chalk.bgBlue('     ') + chalk.bold.black.bgWhite(' Luxafor for Slack ') + chalk.bgYellow('     '));
  console.log('  ' + chalk.bgBlue('     ') + chalk.bold.black.bgWhite('                   ') + chalk.bgYellow('     '));
  console.log('  ' + chalk.bgMagenta('     ') + chalk.bgRed('                        '));
  console.log('  ' + chalk.bgMagenta('     ') + chalk.bgRed('                        '));
  console.log('\n');
}
示例#11
0
		]).then(answer => {
			if (answer.confirm) {
				try {
					write_file(config, file_format);
					console.log(chalk.bgBlue(`\n${file_format} file created successfully..!`));
				} catch(e) {
					console.error(chalk.bgRed(e));
				}
			} else {
				console.warn(chalk.bgRed('\nAborted..!'));
			}
		});
示例#12
0
文件: edit.js 项目: tocausan/Renmin
                        User.findById(req.session.auth._id, function (err, user){
                            switch (true){

                                case(req.body.email != req.session.auth.email && checkEmail != null):
                                    // email already exist
                                    console.log(chalk.bgRed(msg[0]));

                                    return res.format({
                                        html: function(){
                                            res.redirect("?error="+ msg[0]);
                                        },
                                        json: function(){
                                            res.json({error: msg[0]});
                                        }
                                    });
                                    break;

                                case(req.body.username != req.session.auth.username && checkUsername != null):
                                    // username already exist
                                    console.log(chalk.bgRed(msg[1]));

                                    return res.format({
                                        html: function(){
                                            res.redirect("?error="+ msg[1]);
                                        },
                                        json: function(){
                                            res.json({error: msg[1]});
                                        }
                                    });
                                    break;

                                default :
                                    // update profile
                                    user.email = req.body.email;
                                    user.username = req.body.username;
                                    user.firstname = req.body.firstname;
                                    user.lastname = req.body.lastname;
                                    user.save(function(err, lol) {
                                        if(err) console.log(chalk.bgRed(err));
                                        else console.log(chalk.bgGreen(msg[2]));

                                        return res.format({
                                            html: function(){
                                                res.redirect("/profile?success="+ msg[2]);
                                            },
                                            json: function(){
                                                res.json({success: msg[2]});
                                            }
                                        });
                                    });
                                    break;
                            }
                        });
exports.scaffold = function () {

	if (this.templateHelperFiles && this.templateHelperFiles.length > 0) {
		if (this.templateHelperFiles.indexOf(hTimesId) != -1) {
			this.copy(this.generatorHbsHelperPath + "/helper-for.js", this.helperPath + "/helper-for.js");
		}
		if (this.templateHelperFiles.indexOf(hLimitId) != -1) {
			this.copy(this.generatorHbsHelperPath + '/helper-limit.js', this.helperPath + '/helper-limit.js');
		}
		if (this.templateHelperFiles.indexOf(hIfId) != -1) {
			this.copy(this.generatorHbsHelperPath + '/helper-xif.js', this.helperPath + '/helper-xif.js');
		}
		if (this.templateHelperFiles.indexOf(hIfBlockId) != -1) {
			this.copy(this.generatorHbsHelperPath + '/helper-ifBlock.js', this.helperPath + '/helper-ifBlock.js');
		}
		if (this.templateHelperFiles.indexOf(hAutolinkId) != -1) {
			this.npmInstall(['handlebars-helper-autolink'], {'saveDev': true});
			this.log(
				('\n') +
				chalk.bgRed(' Autolink Helper - Please add the following lines to your package.json)') + ('\n') +
				chalk.yellow('\n "keywords": [') +
				chalk.yellow('\n    "handlebars-helper-autolink"') +
				chalk.yellow('\n ]') + ('\n') + ('\n')
			);
		}
		if (this.templateHelperFiles.indexOf(hWrapWithId) != -1) {
			this.copy(this.generatorHbsHelperPath + '/helper-wrapWith.js', this.helperPath + '/helper-wrapWith.js');
			this.copy(this.generatorHbsHelperPath + '/alias.js', this.helperPath + '/alias.js');

			this.log(
				('\n') +
				chalk.bgRed('WrapWith Helper - For further instructions see: http://www.veams.org/generator/prompts/template-engines.html)') +
				chalk.yellow('\n') + ('\n') + ('\n')
			);
		}
		if (this.templateHelperFiles.indexOf(hMergeDataId) != -1) {
			this.copy(this.generatorHbsHelperPath + '/helper-mergeData.js', this.helperPath + '/helper-mergeData.js');

			this.log(
				('\n') +
				chalk.bgRed('MergeData Helper - For further instructions see: http://www.veams.org/generator/prompts/template-engines.html)') +
				chalk.yellow('\n') + ('\n') + ('\n')
			);
		}
		if (this.templateHelperFiles.indexOf(hRandomId) != -1) {
			this.copy(this.generatorHbsHelperPath + '/helper-random.js', this.helperPath + '/helper-random.js');
		}
	}
};
 Promise.all( saveQueue ).then( wrapItUp ).catch(function ( err ) {
   // We don't need to abort the entire
   // operation if something goes wrong.
   winston.log('error', chalk.bgRed(err));
   // Run the callback
   wrapItUp();
 });
示例#15
0
    Company.findOne({ legacyCompanyNumber: hash.legacyCompanyNumber }, function ( err, record ) {
      if( err ) {
        winston.log('error', chalk.bgRed(err));
        throw new Error(err);
      }

      if( !record ) {
        record = new Company( hash );
      } else {
        _.merge( record, hash );
      }

      record.save(function ( err, company ) {
        if( err ) {
          winston.log('error', chalk.bgRed(err));
          throw new Error(err);
        }

        winston.log('info', chalk.dim( 'Saved Company', company.name.company, '-', fulfilled, 'of', hashLen ));

        fulfilled++;
        companies.push( company );

        if( hashLen === fulfilled ) {
          console.log( company );
          callback( companies );
        }

      });
    });
示例#16
0
		}, function(err, results) {

			if (err || !results) {
				logger.log(chalk.bgRed('ERROR'));
				userSocket.emit('update_subtask_complete', {
					// Send error as part of data
					'error': true
				});
				return;
			}

			var task = results;

			task.remove(function(err, results) {

				if (err || !results) {
					logger.log(chalk.bgRed('ERROR'));
					userSocket.emit('delete_task_complete', {
						// Send error as part of data
						'error': true
					});
					return;
				}

				socketServer.sockets.in(userId).emit('delete_task_complete', {
					// Send error as part of data
					'error': false,
					'id': id
				});

			});

		});
示例#17
0
文件: Log.js 项目: laravel/elixir
    /**
     * Log an error message to the console.
     *
     * @param {string} message
     */
    error(message) {
        this.break().message(
            chalk.bgRed(message)
        );

        return this;
    }
示例#18
0
文件: errors.js 项目: momentumft/navy
 prettyPrint() {
   console.log()
   console.log(chalk.bgRed(chalk.bold(' ERROR ')))
   console.log()
   console.log(' ' + this.message)
   console.log()
 }
示例#19
0
 var onComplete = function (result) {
   if (result) {
   } else {
     console.log(chalk.bgRed('!!! Jest tests failed! You should fix them soon. !!!'));
   }
   callback();
 }
示例#20
0
		}, function(err, results) {

			if (err || !results) {
				logger.log(chalk.bgRed('ERROR'));
				userSocket.emit('update_category_complete', {
					// Send error as part of data
					'error': true
				});
				return;
			}

			var category = results;

			category.title = title;
			category.save(function(err, results) {

				if (err || !results) {
					logger.log(chalk.bgRed('ERROR'));
					userSocket.emit('update_category_complete', {
						// Send error as part of data
						'error': true
					});
					return;
				}

				socketServer.sockets.in(userId).emit('update_category_complete', {
					// Send error as part of data
					'error': false,
					'category': category
				});

			});

		});
function consoleHighlightError(errorLine, errorCharStart, errorLength) {
    var rightSideChars = errorLine.length - errorCharStart + errorLength - 1;
    while (errorLine.length + logger_1.Logger.INDENT.length > logger_1.Logger.MAX_LEN) {
        if (errorCharStart > (errorLine.length - errorCharStart + errorLength) && errorCharStart > 5) {
            // larger on left side
            errorLine = errorLine.substr(1);
            errorCharStart--;
        }
        else if (rightSideChars > 1) {
            // larger on right side
            errorLine = errorLine.substr(0, errorLine.length - 1);
            rightSideChars--;
        }
        else {
            break;
        }
    }
    var lineChars = [];
    var lineLength = Math.max(errorLine.length, errorCharStart + errorLength);
    for (var i = 0; i < lineLength; i++) {
        var chr = errorLine.charAt(i);
        if (i >= errorCharStart && i < errorCharStart + errorLength) {
            chr = chalk.bgRed(chr === '' ? ' ' : chr);
        }
        lineChars.push(chr);
    }
    return lineChars.join('');
}
示例#22
0
文件: code-excerpt.js 项目: avajs/ava
test('format line numbers', t => {
	const file = tempWrite.sync([
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'function a() {',
		'\talert();',
		'}'
	].join('\n'));

	const excerpt = codeExcerpt({file, line: 10, isWithinProject: true, isDependency: false});
	const expected = [
		` ${chalk.grey(' 9:')} function a() {`,
		chalk.bgRed(' 10:   alert();    '),
		` ${chalk.grey('11:')} }             `
	].join('\n');

	t.is(excerpt, expected);
	t.end();
});
示例#23
0
文件: id.js 项目: tocausan/Renmin
    Post.findById(id, function (err, post){
        switch (true){
            case(post != null):
                next();
                break;

            default :
                var msg = 'No post has been found there.';
                console.log(chalk.bgRed(msg));

                res.format({
                    html: function(){
                        res.render('error/404', {
                            auth: req.session.auth,
                            message: msg,
                            success: req.query.success,
                            error: req.query.error
                        });
                    },
                    json: function(){
                        res.json({error: msg});
                    }
                });
                break;
        }
    });
示例#24
0
  grunt.registerTask('sterilize', function () {

    const cmd = 'git clean -fdx';
    const ignores = [
      '.aws-config.json',
      'config/kibana.dev.yml'
    ]
      .concat(String(grunt.option('ignore') || '').split(','))
      .map(f => `-e "${f.split('"').join('\\"')}"`)
      .reduce((all, arg) => `${all} ${arg}`, '');

    const stdio = 'inherit';
    execSync(`${cmd} -n ${ignores}`, { stdio });

    const rl = createInterface({
      input: process.stdin,
      output: process.stdout
    });
    const danger = bgRed(white('DANGER'));

    rl.on('close', this.async());
    rl.question(`\n${danger} Do you really want to delete all of the above files?, [N/y] `, function (resp) {
      const yes = resp.toLowerCase().trim()[0] === 'y';
      rl.close();

      if (yes) {
        execSync(`${cmd} ${ignores}`, { stdio });
      }
    });

  });
示例#25
0
 Logger.highlightError = function (errorLine, errorCharStart, errorCharLength) {
     var rightSideChars = errorLine.length - errorCharStart + errorCharLength - 1;
     while (errorLine.length + Logger.LEFT_PADDING.length > Logger.MAX_LEN) {
         if (errorCharStart > (errorLine.length - errorCharStart + errorCharLength) && errorCharStart > 5) {
             // larger on left side
             errorLine = errorLine.substr(1);
             errorCharStart--;
         }
         else if (rightSideChars > 1) {
             // larger on right side
             errorLine = errorLine.substr(0, errorLine.length - 1);
             rightSideChars--;
         }
         else {
             break;
         }
     }
     var lineChars = errorLine.split('');
     for (var i = 0; i < lineChars.length; i++) {
         if (i >= errorCharStart && i < errorCharStart + errorCharLength) {
             lineChars[i] = chalk.bgRed(lineChars[i]);
         }
     }
     return lineChars.join('');
 };
示例#26
0
module.exports = function( path , manifest , appEvents ){

    var chalk = require( "chalk" );
    var _     = require( "underscore" );

    console.log( chalk.bgRed("[ unlinked file ]") , path );


    _.each( manifest , function( value , key ) {

        var keyLength = key.length;
        var parentDir = path.substr( 0 , keyLength );

        if( parentDir == key ){

            var index = value.indexOf( path );

            value.splice( index , 1 );

            appEvents.emit( "manifest:removedFile" , path );

        }

    } );

    console.log( manifest );

};
示例#27
0
exports.load = function(stateFile, migrationsDirectory) {

    var set = new Set(stateFile);
    var stateMigrations = [];
    try {
        if (stateFile) {
            fs.accessSync(stateFile, fs.R_OK);
            try {
                var stateFileContents = fs.readFileSync(stateFile, 'utf8');
                var stateFileJson = JSON.parse(stateFileContents);
                set.pos = stateFileJson.pos;
                stateMigrations = stateFileJson.migrations;
            } catch (e) {
                console.log(chalk.bgRed('Unable to fetch the current state of the migrations from the stateFile! -> Exiting!'));
                process.exit(1);
            }
        }
    } catch (e) {
        // the file does not exist yet... no worries
    }

    var dir = path.resolve(migrationsDirectory);

    fs.readdirSync(dir).filter(function(file) {
        return file.match(/^\d+.*\.js$/);
    }).sort().forEach(function(file) {
        var mod = require(path.join(dir, file));
        var stateMigration = _.find(stateMigrations, {title: file});
        set.addMigration(file, mod.up, mod.down, mod.seedFiles, mod.parent, _.get(stateMigration, 'processed', undefined));
    });

    return set;
};
示例#28
0
			user.save(function(err, results) {

				if (err || !results) {
					logger.log(chalk.bgRed('ERROR'));
					userSocket.emit('update_user_complete', {
						// Send error as part of data
						'error' : true
					});
					return;
				}

				//Have to call session.save() after changing the session in any way - just how socketio works
				session.user = user;
				session.save(function() {

					userSocket.emit('update_user_complete', {
						// Send an error as part of data
						'error' : false,
						'user' : {
							'email' : user.email,
							'phone' : user.phoneNumber
						}
					});

				});

			});
                  company.save(function ( err, companyRecord ) {
                    if( err ) {
                      winston.log('error', chalk.bgRed(err));
                      throw new Error(err);
                    }

                    winston.info(chalk.dim(fulfilled, '/', hashLen, '-', 'Saved company', companyRecord.name.company));

                    rateRecord.company = companyRecord._id;

                    rateRecord.save(function ( err, finalRecord ) {
                      if( err ) {
                        winston.log('error', chalk.bgRed(err));
                        throw new Error(err);
                      }

                      fulfilled++;
                      rates.push( finalRecord );

                      if( hashLen === fulfilled ) {
                        console.log( finalRecord );
                        callback( rates );
                      }
                    }); // rateRecord.save
                  }); // company.save
示例#30
0
文件: db.js 项目: sogehige/SogeBot
    let waitForIt = async (resolve, reject) => {
      if (_.isNil(global.db) || !global.db.engine.connected || _.isNil(global.systems) || _.now() - startup < 10000) {
        return setTimeout(() => waitForIt(resolve, reject), 1000)
      }

      if (__DEBUG__) {
        console.log(chalk.bgRed('*** Cleaning up collections ***'))
      }

      const collections = await global.db.engine.collections()
      for (let c of collections) {
        await global.db.engine.remove(c, {})
      }
      await global.permissions.ensurePreservedPermissionsInDb() // re-do core permissions


      global.oauth.settings.general.channel = 'soge__'
      await variable.isEqual('global.oauth.settings.general.channel', 'soge__')

      global.oauth.settings.general.owners = ['soge__', '__owner__']
      await variable.isEqual('global.oauth.settings.general.owners', ['soge__', '__owner__'])

      global.oauth.settings.broadcaster.username = 'broadcaster'
      await variable.isEqual('global.oauth.settings.broadcaster.username', 'broadcaster')

      resolve()
    }