Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function boot( base_dir, options, callback ){
if( typeof callback !== 'function' ){
if( typeof options === 'function' ){
callback = options;
options = {};
}else{
callback = function(){};
}
}
options = options || {};
var flow = new Flow();
// set global variables
flow.series( function ( next ){
require( './global' )( base_dir, next );
}).
// load logger
series( function ( next ){
var logger = ( function (){
var name = CONF.logger;
if( !name ) return null;
return require( LIB_DIR + '/' + name );
})();
require( CORE_DIR + '/logger' )( logger );
module.exports = function ( current ){
var source = fs.readFileSync( current + 'config/assets.yml', 'utf8' );
var config = yaml.load( source );
var version_path = current + 'public/assets_version.json';
var tmp_dir = current + 'tmp/assets/';
lib.pub_dir = current + 'public/';
var flow = new Flow({
log : true,
minify : true,
uglify : false
});
// check if the dir exist, if it does remove it
flow.series( function ( args, next ){
if( !fs.existsSync( tmp_dir )) return next();
rmdir( tmp_dir, function ( err, dirs, files ){
if( err ) throw err;
next();
});
}).
var tests = require( './inflection' );
var Flow = require( 'node.flow' );
var flow = new Flow();
Object.keys( tests ).forEach( function( test ){
flow.parallel( function ( ready ){
tests[ test ]( ready );
});
});
flow.join().end( function (){
console.log( 'All test passed :)' );
});
var Flow = require( 'node.flow' );
var rater = require( './rater' );
var sidebar = require( './sidebar' );
var flow = new Flow();
module.exports = {
init : function ( express, app ){
flow.series( function ( next ){
if( NODE_ENV === 'dev' ){
var seed = require( './seed' );
seed.init( next );
}
});
flow.series( function ( next ){
rater.init( next );
});
function rm_all_dirs(callback) {
var flow = new Flow();
if (!--pending) {
if (!_dirs.length) return callback();
_dirs.forEach(function (dir) {
flow.parallel(function (ready) {
xfs.exists(dir, function (exists) {
if (!exists) return ready();
xfs.rmdir(dir, function (err) {
if (err) return ready(err);
ready();
});
});
});
var Faker = require( 'faker' );
var mongoose = require( 'mongoose' );
var User = mongoose.model( 'User' );
var Topic = mongoose.model( 'Topic' );
var Comment = mongoose.model( 'Comment' );
var Tag = mongoose.model( 'Tag' );
var Notif = mongoose.model( 'Notification' );
var Cache = mongoose.model( 'Cache' );
var Flow = require( 'node.flow' );
var flow = new Flow();
var random = function ( max ){
return Faker.Helpers.randomNumber( max );
};
var random_user = function (){
return {
google_id : ( random( 1000000 ).toString()),
name : Faker.Name.findName(),
email : Faker.Internet.email(),
};
};
var random_topic = function (){
return {
title : Faker.Lorem.sentence(),
User.find( function ( err, users ){
if( err ){
LOG.error( 500, '[libs][rater][init] Having trouble finding users' );
callback && callback();
}
var flow = new Flow();
var RATE_PER_TOPIC = 5;
var RATE_PER_COMMENT = 1;
users.forEach( function ( user ){
flow.series( function ( next ){
user.rating =
user.topics.length * RATE_PER_TOPIC +
user.comments.length * RATE_PER_COMMENT;
user.save( function ( err, user, count ){
if( err ) return LOG.error( 500,
'[libs][rater][init] Having trouble saving the user' );
next();
});
create_all : function ( names, callback ){
var self = this;
var flow = new Flow();
names.forEach( function ( name ){
flow.series( function ( name, next ){
self.findOne({ name : name }, function ( err, tag ){
if( err ) return flow.end( function (){
callback( err );
});
if( tag ) return next();
new self({
name : name
}).save( function ( err, tag, count ){
if( err ) return flow.end( function (){
callback( err );
});
init : function ( callback ){
var flow = new Flow();
var cache = {};
var trunk_tags = [];
var trunk_users = [];
var trunk_issues = [];
function compare( a, b ){
if( a > b ) return 1;
if( a < b ) return -1;
return 0;
}
flow.series( function ( next ){
Tag.find(
function ( err, tags ){
if( err ) return LOG.error( 500,
'[libs][sidebar][init] Having trouble finding tags' );
var Faker = require( 'Faker' );
var User = Model( 'User' );
var Topic = Model( 'Topic' );
var Comment = Model( 'Comment' );
var Tag = Model( 'Tag' );
var Notif = Model( 'Notification' );
var Cache = Model( 'Cache' );
var Flow = require( 'node.flow' );
var flow = new Flow();
var random = function ( max ){
return Faker.Helpers.randomNumber( max );
};
var random_user = function (){
return {
google_id : ( random( 1000000 ).toString()),
name : Faker.Name.findName(),
email : Faker.Internet.email(),
};
};
var random_topic = function (){
return {
title : Faker.Lorem.sentence(),