_(files) .filter(file => fs.existsSync(file)) .map(file => yaml.safeLoad(fs.readFileSync(file))) .thru(data => _.merge({}, ...data)) .thru(data => { // Set the php version // @TODO: what is the best version here? data.php = _.toString(_.get(data, 'php_version', '5.6')); // Set the webroot data.webroot = (_.get(data, 'web_docroot', false)) ? 'web' : '.'; // Set the drush version data.drush = _.toString(_.get(data, 'drush_version', '8')); // if drush version is less than 8, use 8 anyway if (data.drush < 8) data.drush = 8; // return return data; }) .value()
/* * Helper to get an executable */ const getDockerBin = (bin, base) => { // Do platform appropriate things to get started const join = (process.platform === 'win32') ? path.win32.join : path.posix.join; let binPath = (process.platform === 'win32') ? join(base, `${bin}.exe`) : join(base, bin); // Use PATH compose executable on posix if ours does not exist if (process.platform !== 'win32' && (!fs.existsSync(binPath) || fs.statSync(binPath).isDirectory())) { binPath = _.toString(shell.which(bin)); } // If the binpath still does not exist then we should set to false and handle downstream if (!fs.existsSync(binPath)) return false; // Otherwise return a normalized binpath switch (process.platform) { case 'darwin': return path.posix.normalize(binPath); case 'linux': return path.posix.normalize(binPath); case 'win32': return path.win32.normalize(binPath); } }
/* * Get services wrapper */ const buildDockerCmd = cmd => { switch (process.platform) { case 'darwin': return ['open', macOSBase]; case 'linux': if (_.includes(_.toString(shell.which('systemctl')), 'systemctl')) { return ['sudo', 'systemctl', cmd, 'docker']; } else { return ['sudo', 'service', 'docker'].concat(cmd); } case 'win32': const base = process.env.ProgramW6432 || process.env.ProgramFiles; const dockerBin = base + '\\Docker\\Docker\\Docker Desktop.exe'; return ['cmd', '/C', `"${dockerBin}"`]; } }
// Helper to bind exposed ports to the correct address const normalizeBind = (bind, address = '127.0.0.1') => { // If bind is not a string, return right away if (!_.isString(bind)) return bind; // Otherwise attempt to do stuff const pieces = _.toString(bind).split(':'); // If we have three pieces then honor the users choice if (_.size(pieces) === 3) return bind; // Unshift the address to the front and return else if (_.size(pieces) === 2) { pieces.unshift(address); return pieces.join(':'); }; // Otherwise we can just return the address prefixed to the bind return `${address}::${bind}`; }
LANDO_EXTRA_NAMES: `DNS.100 = *.${proxyDomain}`, LANDO_PROXY_CONFIG_FILE: '/proxy_config/proxy.yaml', LANDO_PROXY_PASSTHRU: _.toString(proxyPassThru), LANDO_VERSION: version, },
describe('#which', () => { const savePath = process.env.PATH; beforeEach(() => { process.env.PATH = os.tmpdir(); const bin = {}; const content = 'Gorillaz on buildings throwing explosive bananas at each other with mathematical precision'; bin[path.join(os.tmpdir(), 'GORILLA.BAS')] = content; filesystem(bin); }); it('should return the same as shelljs.which', () => { const shell = new Shell(); const which1 = shell.which('GORILLA.BAS'); const which2 = _shell.which('GORILLA.BAS'); _.toString(which1).should.equal(_.toString(which2)); }); it('should return null if command is not found', () => { const shell = new Shell(); const wolfenstein = shell.which('WOLFENSTEIN2D.exe'); expect(wolfenstein).to.be.null; }); afterEach(() => { filesystem.restore(); process.env.PATH = savePath; }); });
service.environment.LANDO_PROXY_PASSTHRU = _.toString(lando.config.proxyPassThru); const proxyVolume = `${lando.config.proxyName}_proxy_config`; return {
addCameraToCache(id, camera){ if(typeof id !== 'string'){ id = _.toString(id); } this.cameras = this.cameras.set(id, camera); }
processedSVG.replace( /viewBox="[^\"]+"/, ( match ) => { return match.replace( new RegExp( escapeRegexp( _.toString( dimensions.width ) ), 'g' ), width ); } )
/** * Validate the winners array. * @param {Array} winners the Winner Array * @param {String} winchallengeIdners the challenge ID */ async function validateWinners (winners, challengeId) { const challengeResources = await helper.getChallengeResources(challengeId) const registrants = _.filter(challengeResources, r => r.roleId === config.SUBMITTER_ROLE_ID) for (const winner of winners) { if (!_.find(registrants, r => _.toString(r.memberId) === _.toString(winner.userId))) { throw new errors.BadRequestError(`Member with userId: ${winner.userId} is not registered on the challenge`) } const diffWinners = _.differenceWith(winners, [winner], _.isEqual) if (diffWinners.length + 1 !== winners.length) { throw new errors.BadRequestError(`Duplicate member with placement: ${helper.toString(winner)}`) } // find another member with the placement const placementExists = _.find(diffWinners, function (w) { return w.placement === winner.placement }) if (placementExists && (placementExists.userId !== winner.userId || placementExists.handle !== winner.handle)) { throw new errors.BadRequestError(`Only one member can have a placement: ${winner.placement}`) } // find another placement for a member const memberExists = _.find(diffWinners, function (w) { return w.userId === winner.userId }) if (memberExists && memberExists.placement !== winner.placement) { throw new errors.BadRequestError(`The same member ${winner.userId} cannot have multiple placements`) } } }
addUserToCache(id, user) { id = _.toString(id); this.users = this.users.set(id, user); }
processedSVG.replace( /viewBox="[^\"]+"/, ( match ) => { return match.replace( new RegExp( escapeRegexp( _.toString( dimensions.height ) ), 'g' ), height ); } )