connection .authenticate() .then(() => { console.info('INFO - Database connected.') }) .catch(err => { console.error('ERROR - Unable to connect to the database:', err) })
/* * Ping connection. */ ping() { return Promise.resolve(true); }
// Start listening Promise.fromNode(cb => { api.listen(config.LANDO_API_PORT, cb); }) // Load our routes .then(() => { fs.readdirSync(path.join(__dirname, 'routes')).map(file => { require(`./routes/${file}`)(api, handler, {config, slack}); log.info('Loaded route %s', file); }); log.info('Listening on port: %s', config.LANDO_API_PORT); });
// Helper to get sites for autocomplete const getAutoCompleteSites = (answers, lando, input = null) => { if (!_.isEmpty(pantheonSites)) { return lando.Promise.resolve(pantheonSites).filter(site => _.startsWith(site.name, input)); } else { const api = new PantheonApiClient(answers['pantheon-auth'], lando.log); return api.auth().then(() => api.getSites().map(site => ({name: site.name, value: site.name}))).then(sites => { pantheonSites = sites; return pantheonSites; }); }; }
test('@taskr/clear: directory', co(function * (t) { t.plan(1); yield create({ * a(f) { const src = `${dir1}/foo`; yield f.$.write(src); yield f.clear(dir1); t.false(exists(src), 'directory was deleted'); } }).start('a'); }));
*parallel(tasks, opts) { try { yield Promise.all(tasks.map(t => this.start(t, opts))); } catch (err) { // } }
client.setKeySerializer(function(_) { keySerializerCalled = true; t.deepEqual(_, k); return new Promise(function(resolve) { resolve('key'); }); });
/* * Insert document into cluster. */ report(data) { const {client, index, type} = this; // Insert document into cluster. return Promise.fromNode(cb => { client.index({index, type, body: data}, cb); }); }
// Bootstrap lando at the correct level lando.bootstrap(bsLevel).then(lando => { // If bootstrap level is APP then we need to get and init our app to generate the app task cache if (bsLevel === 'APP') { lando.getApp().init().then(() => cli.run(bootstrap.getTasks(config, cli.argv()), config)); // Otherwise run as yooz } else { cli.run(bootstrap.getTasks(config, cli.argv()), config); } });
/* * Helper to load in all app plugins */ const loadPlugins = (app, lando) => Promise.resolve(app.plugins.registry) // Filter out .filter(plugin => _.has(plugin, 'app')) // LOADEM! .map(plugin => app.plugins.load(plugin, plugin.app, app, lando)) // Remove any naughty shit .map(plugin => _.pick(plugin.data, ['config', 'composeData', 'env', 'labels'])) // Merge minotaur .each(result => _.merge(app, result))
test("plugins.load", co(function* (t) { // const out1 = yield plugs.load(join("/fake123", "taskfile.js")) // t.true(Array.isArray(out1) && out1.length === 0, "via invalid file returns an empty array") // ^^ logs error message to test disrupts formatting const out = yield plugs.load(taskfile) t.ok(Array.isArray(out), "returns an array") t.equal(out.length, 7, "filters down to fly|taskr plugins only") t.equal(typeof out[0], "function", "is an array of functions") t.equal(out[2], undefined, "returns `undefined` for faulty plugins") t.end() }))
*parallel(tasks, opts) { try { yield Promise.all(tasks.map(t => this.start(t, opts))); } catch (err) { // } }
connection .authenticate() .then(() => { console.info('INFO - Database connected.') }) .catch(err => { console.error('ERROR - Unable to connect to the database:', err) })