Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function readLink (cb) {
if (conf.targetProject) return cb();
// Determine expected location of treeline.json file
var jsonPath = process.cwd() + '/treeline.json';
jsonPath = path.resolve(jsonPath);
async.auto({
readFile: function (cb) {
fse.readJSON(jsonPath, function (err, json){
if (err) {
// If the file simply doesn't exist, we won't call this an error
// instead, exit silently
if (err instanceof Error && err.errno===34) {
return cb();
}
// If some other sort of error occurred, we'll assume the file is corrupted.
log.error('Linkfile in current directory is corrupted.');
log.error('Please run `treeline unlink` here, then try again.'.grey);
return cb(err);
}
var bower = require('bower');
var fsx = require('fs-extra');
var async = require('async');
/**
* Update client-side dependencies
*/
async.auto({
'sails.io.js': function(cb) {
bower.commands
.install(['sails.io.js'], {
save: false
}, { /* custom config */ })
.on('end', function(installed) {
fsx.copy(
'bower_components/sails.io.js/dist/sails.io.js',
'templates/assets/js/dependencies/sails.io.js',
cb);
});
},
// ... future front-end dependencies here ...
var clientConfig = JSON.parse(JSON.stringify(this._config.client))
// add the auth
clientConfig.auth = request.auth.credentials
// encode the cookie
cookie = encodeURIComponent(JSON.stringify(clientConfig))
// set the cookie
return reply(request.response.state('config', cookie))
}
return reply.continue()
}.bind(this))
async.auto({
add_auth: function (callback) {
hapi.register(BasicAuth, function (error) {
hapi.auth.strategy('simple', 'basic', {
validateFunc: this._validateUser.bind(this)
})
callback(error)
}.bind(this))
}.bind(this),
add_rest: ['add_auth', function (callback) {
var columbo = new Columbo({
resourceDirectory: path.resolve(__dirname + '/resources'),
resourceCreator: function (resource, name, callback) {
this._container.createAndRegister(name, resource, function (error, result) {
callback(error, result)
})
}.bind(this),
function acquireLink (cb) {
if (conf.targetProject) return cb();
async.auto({
// Load config
config: readConfig,
// Use cached credentials or enter login flow
credentials: authenticate,
readLinkfile: ['credentials', readLink],
// Fetch apps available to this user from treeline server
// or prompt user for login credentials if necessary.
// Ask user to pick an app
target: ['readLinkfile', doChooseApp],
writeLinkfile: ['target', writeLinkfile]
function readData(cb) {
console.log('START READING');
async.auto({
storage: createAndOpenStorage,
server: ['storage', createServerHost],
mice: ['server', openServerMice],
close_all: ['mice', closeServer]
}, function onReadFinished(err, results) {
if (err) {
return cb(err);
}
console.log('FINISHED READING');
cb(null, results.mice);
* @package sentiment
* @author Andrew Sliwinski
*/
/**
* Dependencies
*/
var async = require('async'),
test = require('tap').test,
target = require(__dirname + '/../lib/index.js');
/**
* Suite
*/
async.auto({
negative: function (callback) {
target('Hey you worthless scumbag', callback);
},
positive: function (callback) {
target('This is so cool', callback);
},
n2: function (callback) {
target('Cats are stupid.', callback);
},
p2: function (callback) {
target('Cats are totally amazing!', callback);
},
if (this._groups) {
return callback(null, this._groups);
}
const tasks = {};
Object.keys(this.groups).forEach((group) => {
tasks[group] = function (done) {
AdminGroup.findById(group, done);
};
});
Async.auto(tasks, (err, results) => {
if (err) {
return callback(err);
}
this._groups = results;
callback(null, this._groups);
});
}
function compactTrigger(storePath, returnErrorAndShouldCompact) {
async.auto({
getDataFileStats: function (done) {
fs.stat(storePath + DATA_FILE_EXTENSION, done);
},
existsLogFile: function (done) {
fs.exists(storePath + DATA_LOG_FILE_EXTENSION, function (exists) {
done(undefined, exists);
});
},
getLogFileStats: ['existsLogFile', function (done, results) {
if (!results.existsLogFile) {
done();
return;
}
fs.stat(storePath + DATA_LOG_FILE_EXTENSION, done);
}]
}, function (error, results) {
if (this.roles.account) {
tasks.account = function (done) {
Account.findById(self.roles.account.id, done);
};
}
if (this.roles.admin) {
tasks.admin = function (done) {
Admin.findById(self.roles.admin.id, done);
};
}
Async.auto(tasks, (err, results) => {
if (err) {
return callback(err);
}
self._roles = results;
callback(null, self._roles);
});
}
});
static findByCredentials(username, password, callback) {
const self = this;
Async.auto({
user: function (done) {
const query = {
isActive: true
};
if (username.indexOf('@') > -1) {
query.email = username.toLowerCase();
}
else {
query.username = username.toLowerCase();
}
self.findOne(query, done);
},
passwordMatch: ['user', function (results, done) {