const needsWrapping = s => !_.startsWith(s, '\'') && !_.endsWith(s, '\'') && _.includes(s, 'lando.')
.filter(path => _.endsWith(path, '.js')) .value()
.filter(name => !_.endsWith(name, '-secured')) .value() .join(',');
_.forEach(Category.associations, async association => { const search = (_.endsWith(association.nature, 'One')) ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } }; const update = (_.endsWith(association.nature, 'One')) ? { [association.via]: null } : { $pull: { [association.via]: data._id } }; await strapi.models[association.model || association.collection].update( search, update, { multi: true }); });
findApplication(hostname) { const application = this._state.applications.find( a => hostname === this._getApplicationHostname(a) ) || this._state.applications.find(a => _.endsWith(hostname, `.${this._getApplicationHostname(a)}`) ); if (!application) return null; this._triggerAsync(async () => { if (this._terminals[application.name]) return; if (this._applicationLocks[application.name]) return; await this._ensureApplicationUp(application); }); return application; }
_.reduce(matches, function (newMatches, match) { var newIndex = _.findIndex(match.segments, function (segment) { return _.startsWith(segment, '{') && _.endsWith(segment, '}'); }, lastIndex + 1); // Complete static match so use some value that can't be exceeded if (newIndex === -1) { newIndex = Infinity; } if (newIndex > nextIndex) { nextIndex = newIndex; newMatches = [match]; } else if (newIndex === nextIndex) { newMatches.push(match); } return newMatches; }, [])
output.forEach(function (line, i) { if (on) { let parts = line.split("="); if ((parts.length === 2 && parts[0].trim()) || (parts.length === 1 && i !== output.length - 1 && output[i + 1].trim()[0] === "=")) { let gen = parts[0].trim(); if (_.endsWith(gen, arch)) { gen = gen.substr(0, gen.length - arch.length); } gens.push(gen); } } if (line.trim() === "Generators") { on = true; } });
load(file) { if(!this.logger) { this.logger = this.akyuu.logger.get("service-loader"); } const directory = path.join(`${this.akyuu.projectRoot}/services`, file); const filenames = fs.readdirSync(directory); for(let i = 0; i < filenames.length; i++) { const stat = fs.statSync(`${directory}/${filenames[i]}`); if(stat.isDirectory()) { this.load(`${file}/${filenames[i]}`); } else if(_.endsWith(filenames[i], ".js")) { const ApiClass = require(`${directory}/${filenames[i]}`); const apiClassInstance = new ApiClass(); let apiClassName = apiClassInstance.constructor.name; apiClassName = Case.snake(apiClassName); this.services[apiClassName] = apiClassInstance; this.serviceClasses[apiClassName] = ApiClass; this.logger.info(`Service \`${apiClassName}\` loaded.`); } } }
filesystem.readdirSync('./').filter(file => _.endsWith(file, '.log')).map(file => new Promise((resolve) => { exec(`cat ${file} | grep "tradeHistory"`, (error, stdout, stderr) => { if (error || stderr || stdout.trim().length === 0) { log.warn(`${file} isn't useful`); return resolve(true); } stdout.split('\n').filter((logMessage) => { if (logMessage.trim() === '') { return false; } try { JSON.parse(logMessage); } catch (e) { log.warn(`${logMessage} isn't useful`); return false; } return logMessage; }).forEach((logMessage) => { const obj = JSON.parse(logMessage); buySellPoints[obj.timestamp] = `${obj.timestamp},${obj.price},${obj.buyOrSell}`; }); return resolve(true); }); }))
/** * Normalizes collection paths. * * Examples: * / => (empty string) * /users => /users * /users/jdoe/ => /users/jdoe * * @param {string} collection * @returns {string} */ function normalizeCollection (collection) { // Normalize the root path as an empty string collection = _(collection).toString(); if (_.isEmpty(collection) || collection === "/" || collection === "//") { return ""; } // Add a leading slash if (!_.startsWith(collection, "/")) { collection = "/" + collection; } // Remove a trailing slash if (_.endsWith(collection, "/")) { collection = collection.substring(0, collection.length - 1); } return collection; }
load(file) { if(!this.logger) { this.logger = this.akyuu.logger.get("model-loader"); } const directory = path.join(`${this.akyuu.projectRoot}/models`, file); let filenames; try { filenames = fs.readdirSync(directory); } catch(e) { return; } for(let i = 0; i < filenames.length; i++) { const stat = fs.statSync(`${directory}/${filenames[i]}`); if(stat.isDirectory()) { this.load(`${file}/${filenames[i]}`); } else if(_.endsWith(filenames[i], ".js")) { const modelName = _.upperFirst(_.camelCase(filenames[i].substr(0, filenames[i].length - 3))); this.models[modelName] = require(`${directory}/${filenames[i]}`); this.logger.info(`Model \`${modelName}\` loaded.`); } } }
_.forEach(Organisation.associations, async association => { const search = (_.endsWith(association.nature, 'One')) ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } }; const update = (_.endsWith(association.nature, 'One')) ? { [association.via]: null } : { $pull: { [association.via]: data._id } }; await strapi.models[association.model || association.collection].update( search, update, { multi: true }); });
_.forEach(Pages.associations, async association => { const search = (_.endsWith(association.nature, 'One')) ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } }; const update = (_.endsWith(association.nature, 'One')) ? { [association.via]: null } : { $pull: { [association.via]: data._id } }; await strapi.models[association.model || association.collection].update( search, update, { multi: true }); });
_.forEach(Products.associations, async association => { const search = (_.endsWith(association.nature, 'One')) ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } }; const update = (_.endsWith(association.nature, 'One')) ? { [association.via]: null } : { $pull: { [association.via]: data._id } }; await strapi.models[association.model || association.collection].update( search, update, { multi: true }); });
_.forEach(Zit.associations, async association => { const search = (_.endsWith(association.nature, 'One')) ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } }; const update = (_.endsWith(association.nature, 'One')) ? { [association.via]: null } : { $pull: { [association.via]: data._id } }; await strapi.models[association.model || association.collection].update( search, update, { multi: true }); });