How to use getGitRev method in Appium

Best JavaScript code snippet using appium

customer.controller.js

Source:customer.controller.js Github

copy

Full Screen

...94 console.log(err);95 await ErrorLog.create({96 method: 'searchCustomers',97 controller: 'customer.controller',98 revision: getGitRev(),99 stack: err.stack,100 error: err,101 user: req.user._id102 });103 return res.status(500).json(err);104 });105}106/**107 * Get customers for this company108 */109export function findCustomersThisCompany(req, res) {110 const companyId = req.params.companyId;111 // Check access112 if (companyId !== req.user.company.toString()) {113 return res.status(401).json();114 }115 Customer.find({116 company: companyId117 })118 .then(customers => res.json(customers))119 .catch(async err => {120 console.log('**************FIND CUSTOMERS BY COMPANY ERROR**********');121 console.log(err);122 await ErrorLog.create({123 method: 'findCustomersThisCompany',124 controller: 'customer.controller',125 revision: getGitRev(),126 stack: err.stack,127 error: err,128 user: req.user._id129 });130 return res.status(500).json({131 error: 'Could not retrieve customers'132 });133 });134}135/**136 * Retrieve customers for this store137 */138export function getCustomersThisStore(req, res) {139 Customer.find({store: req.params.store})140 .then(customers => res.json({customers}))141 .catch(async err => {142 await ErrorLog.create({143 method: 'getCustomersThisStore',144 controller: 'customer.controller',145 revision: getGitRev(),146 stack: err.stack,147 error: err,148 user: req.user._id149 });150 return res.status(500).json({});151 });152}153/**154 * Retrieve customer by ID155 * @param req156 * @param res157 */158export async function findCustomerById(req, res) {159 const {customerId} = req.params;160 const validObjectId = isValidObjectId(customerId);161 // Valid customer162 if (validObjectId) {163 Customer.findById(customerId)164 .populate('store')165 .populate({166 path: 'company',167 populate: [168 {169 path: 'settings',170 model: 'CompanySettings'171 }172 ]173 })174 .then(customer => res.json(customer))175 .catch(async err => {176 console.log('**************FIND CUSTOMER BY ID ERROR**********');177 console.log(err);178 await ErrorLog.create({179 method: 'findCustomerById',180 controller: 'customer.controller',181 revision: getGitRev(),182 stack: err.stack,183 error: err,184 user: req.user._id185 });186 return res.status(500).json(err);187 });188 // Default, no customer selected189 } else if (customerId === 'default') {190 return res.json({191 defaultCustomer: true192 });193 } else {194 return res.status(500).json({err: 'Invalid customer ID'});195 }196}197/**198 * Create a new customer199 * @param req200 * @param res201 */202export function newCustomer(req, res) {203 const {company} = req.user;204 let store = req.user.store;205 const customerData = req.body;206 if (customerData.store) {207 store = customerData.store;208 }209 let companySettings;210 return Store.findById(store)211 .then(store => {212 if (!store) {213 res.status(404).json({err: "Store not found"});214 throw 'noStore';215 }216 return Company.findById(company)217 })218 .then(company => {219 return company.getSettings();220 })221 .then(settings => {222 companySettings = settings;223 if (!settings.customerDataRequired) {224 ['firstName', 'lastName', 'address1', 'city', 'state', 'zip', 'phone', 'fullName', 'email'].forEach(attr => {225 if (typeof customerData[attr] === 'undefined') {226 customerData[attr] = ' ';227 }228 });229 // Front-end likes to push an object when no state is selected.230 // Just ignore whatever it is that's not a string.231 if (typeof customerData.state !== 'string') {232 customerData.state = ' ';233 }234 }235 const customer = new Customer(customerData);236 customer.company = company;237 return customer.save();238 })239 .then(customer => {240 if (!companySettings.customerDataRequired) {241 const newCustomerData = {};242 ['firstName', 'lastName', 'address1', 'city', 'state', 'zip', 'phone', 'fullName', 'email'].forEach(attr => {243 if (!customer[attr].replace(/\s/g, '').length) {244 newCustomerData[attr] = '';245 }246 });247 Customer.update({_id: customer._id}, newCustomerData).then(() => {});248 return Customer.findById(customer._id);249 }250 return customer;251 })252 .then(customer => {253 return res.json(customer);254 })255 .catch(async err => {256 if (err === 'noStore') {257 return;258 }259 if (err.name && err.name === 'ValidationError') {260 return res.status(400).json(err);261 }262 await ErrorLog.create({263 method: 'newCustomer',264 controller: 'customer.controller',265 revision: getGitRev(),266 stack: err.stack,267 error: err,268 user: req.user._id269 });270 console.log('********************ERROR IN NEWCUSTOMER********************');271 console.log(err);272 res.status(500).json(err);273 });274}275/**276 * Update customer277 * @param req278 * @param res279 */280export function updateCustomer(req, res) {281 const {customerId} = req.params;282 const company = req.user.company;283 const body = req.body;284 Customer.findOne({_id: customerId, company})285 .then(customer => {286 if (!customer) {287 return res.status(404);288 }289 const editable = [290 'address1',291 'address2',292 'city',293 'enabled',294 'firstName',295 'lastName',296 'middleName',297 'phone',298 'state',299 'stateId',300 'zip',301 'email'302 ];303 editable.forEach(key => {304 customer[key] = body[key];305 });306 return customer.save();307 })308 .then(() => res.json())309 .catch(async err => {310 console.log('**************ERR IN UPDATE CUSTOMER**********');311 console.log(err);312 await ErrorLog.create({313 method: 'updateCustomer',314 controller: 'customer.controller',315 revision: getGitRev(),316 stack: err.stack,317 error: err,318 user: req.user._id319 });320 return res.status(500).json(err);321 })322}323/**324 * Assign a customer to a card325 */326export function assignCustomerToCard(req, res) {327 const {customer, card} = req.body;328 Card.findById(card._id)329 .then(card => {330 card.customer = customer._id;331 return card.save();332 })333 .then(card => {334 return Card.findById(card._id)335 .populate({336 path: 'retailer',337 populate: {338 path: 'buyRateRelations',339 model: 'BuyRate'340 }341 })342 .populate('customer');343 })344 .then(card => res.json(card))345 .catch(async err => {346 console.log('**************ASSIGN CUSTOMER TO CARD ERR**********');347 console.log(err);348 await ErrorLog.create({349 method: 'assignCustomerToCard',350 controller: 'customer.controller',351 revision: getGitRev(),352 stack: err.stack,353 error: err,354 user: req.user._id355 });356 return res.status(500).json({357 message: 'Could not assign customer to card'358 });359 });360}361/**362 * Find customers with denials363 */364export function findCustomersWithDenials(req, res) {365 return Customer366 .find()367 .sort({rejectionTotal: -1})368 .then(customers => res.json({customers}))369 .catch(async err => {370 console.log('**************ERR FINDING CUSTOMERS WITH DENIALS**********');371 console.log(err);372 await ErrorLog.create({373 method: 'findCustomersWithDenials',374 controller: 'customer.controller',375 revision: getGitRev(),376 stack: err.stack,377 error: err,378 user: req.user._id379 });380 return res.status(500).json(err);381 });382}383/**384 * Update customer denial total385 */386export function updateCustomerDenialTotal(req, res) {387 const {_id, newTotal} = req.body;388 Customer.findById(_id)389 .then(customer => {390 if (customer) {391 customer.rejectionTotal = newTotal;392 return customer.save();393 } else {394 throw 'notFound';395 }396 })397 .then(customer => res.json(customer))398 .catch(async err => {399 console.log('**************ERR IN UPDATE CUSTOMER REJECTION TOTAL**********');400 console.log(err);401 await ErrorLog.create({402 method: 'updateCustomerDenialTotal',403 controller: 'customer.controller',404 revision: getGitRev(),405 stack: err.stack,406 error: err,407 user: req.user._id408 });409 return res.status(500).json({err});410 });411}412/**413 * Get all customers414 */415export function getAllCustomers(req, res) {416 Customer.find()417 .then(customers => res.json(customers))418 .catch(async err => {419 await ErrorLog.create({420 method: 'getAllCustomers',421 controller: 'customer.controller',422 revision: getGitRev(),423 stack: err.stack,424 error: err,425 user: req.user._id426 });427 return res.status(500).json({});428 });429}430/**431 * Make a cash payment against denials432 */433export function cashPayment(req, res) {434 const {amount, userTime, rejectionTotal, store, company} = req.body;435 const user = req.user;436 Customer.findById(req.params.customerId)437 .then(customer => {438 const previousTotal = customer.rejectionTotal;439 customer.rejectionTotal = previousTotal - parseFloat(amount);440 const denialPayment = new DenialPayment({441 amount,442 userTime,443 customer: customer._id444 });445 const receipt = new Receipt({446 userTime,447 rejectionTotal,448 total: amount,449 appliedTowardsDenials: amount,450 grandTotal: amount,451 company,452 store,453 customer: customer._id,454 user: user._id455 });456 return Promise.all([457 denialPayment.save(),458 customer.save(),459 receipt.save()460 ]);461 })462 .then(models => {463 const [payment, customer, receipt] = models;464 return res.json({data: receipt});465 })466 .catch(async err => {467 await ErrorLog.create({468 method: 'cashPayment',469 controller: 'customer.controller',470 revision: getGitRev(),471 stack: err.stack,472 error: err,473 user: req.user._id474 });475 return res.status(500).json({});476 });...

Full Screen

Full Screen

Gruntfile.js

Source:Gruntfile.js Github

copy

Full Screen

...111 });112 grunt.registerTask('setGitRev', function (rev) {113 var done = this.async();114 if (typeof rev === "undefined") {115 getGitRev(function (err, rev) {116 if (err) throw err;117 setGitRev(grunt, rev, done);118 });119 } else {120 setGitRev(grunt, rev, done);121 }122 });...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

...23async function getAppiumConfig () {24 let stat = await fs.stat(path.resolve(__dirname, '..'));25 let built = stat.mtime.getTime();26 let config = {27 'git-sha': await getGitRev(),28 built,29 version: APPIUM_VER,30 };31 return config;32}33function checkNodeOk () {34 let [major, minor] = getNodeVersion();35 if (major < 4) {36 let msg = `Node version must be >= 4. Currently ${major}.${minor}`;37 logger.errorAndThrow(msg);38 }39}40function warnNodeDeprecations () {41 let [major] = getNodeVersion();...

Full Screen

Full Screen

ci-metrics.js

Source:ci-metrics.js Github

copy

Full Screen

...37 // rewrite `init` so `eventTimings` is on38 let init = driver.init;39 driver.init = async function (caps) {40 try {41 gitRev = await getGitRev(); // jshint ignore: line42 } catch (err) {43 log.warn(`Unable to parse git rev and branch: ${err.message}`);44 log.warn('Event timing data will be incomplete');45 }46 caps.eventTimings = true;47 return await init.call(driver, caps);48 };49 // rewrite `quit` to get the event timings and pass them on50 let quit = driver.quit;51 driver.quit = async function () {52 let caps = await driver.sessionCapabilities();53 let events = Object.assign({}, caps.events, {54 // TODO: add identification info when the parser can handle it55 // build: {...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...34 console.log(error.response.body.errors);35 await ErrorLog.create({36 method: 'sendResetPasswordEmail',37 controller: 'auth.forgot',38 revision: getGitRev(),39 stack: error.stack,40 error: error.response.body.errors,41 user: req.user._id42 });43 } else {44 await ErrorLog.create({45 method: 'sendResetPasswordEmail',46 controller: 'auth.forgot',47 revision: getGitRev(),48 stack: error.stack,49 error: error,50 user: req.user._id51 });52 }53 }54 });55 setTimeout(function () {56 resetPassword.remove();57 }, tokenLifespan);58 return res.json({});59 })60 .catch(async err => {61 if (err === 'notFound') {62 return res.status(400).json({error: 'User not found.'});63 }64 await ErrorLog.create({65 method: 'forgotpassword',66 controller: 'auth.forgot',67 revision: getGitRev(),68 stack: err.stack,69 error: err,70 user: req.user._id71 });72 console.log('*****************ERROR IN FORGOTPASSWORD*****************');73 console.log(err);74 return res.status(500).json({error: 'Something went wrong.'});75 });76});...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var appium = require('appium');2appium.getGitRev(function(err, rev) {3 console.log(rev);4});5var appium = require('appium');6console.log(appium.getGitRevSync());7var appium = require('appium');8appium.getAppiumVersion(function(err, rev) {9 console.log(rev);10});11var appium = require('appium');12console.log(appium.getAppiumVersionSync());13var appium = require('appium');14appium.getGitRev(function(err, rev) {15 console.log(rev);16});17var appium = require('appium');18console.log(appium.getGitRevSync());19var appium = require('appium');20appium.getAppiumVersion(function(err, rev) {21 console.log(rev);22});23var appium = require('appium');24console.log(appium.getAppiumVersionSync());25var appium = require('appium');26appium.getGitRev(function(err, rev) {27 console.log(rev);28});29var appium = require('appium');30console.log(appium.getGitRevSync());31var appium = require('appium');32appium.getAppiumVersion(function(err, rev) {33 console.log(rev);34});35var appium = require('appium');36console.log(appium.getAppiumVersionSync());37var appium = require('app

Full Screen

Using AI Code Generation

copy

Full Screen

1var AppiumHelper = require('appium-helper').AppiumHelper;2AppiumHelper.getGitRev(function(err, rev) {3 if (err) {4 console.log(err);5 } else {6 console.log('Git revision is: ' + rev);7 }8});9Copyright (c) 2016-present Appium Committers10Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Full Screen

Using AI Code Generation

copy

Full Screen

1const AppiumHelper = require('appium-helper');2var appiumHelper = new AppiumHelper();3var gitRev = appiumHelper.getGitRev();4console.log(gitRev);5const AppiumHelper = require('appium-helper');6var appiumHelper = new AppiumHelper();7var gitRev = appiumHelper.getGitRev();8console.log(gitRev);9const AppiumHelper = require('appium-helper');10var appiumHelper = new AppiumHelper();11var gitRev = appiumHelper.getGitRev();12console.log(gitRev);13const AppiumHelper = require('appium-helper');14var appiumHelper = new AppiumHelper();15var gitRev = appiumHelper.getGitRev();16console.log(gitRev);17const AppiumHelper = require('appium-helper');18var appiumHelper = new AppiumHelper();19var gitRev = appiumHelper.getGitRev();20console.log(gitRev);21const AppiumHelper = require('appium-helper');22var appiumHelper = new AppiumHelper();23var gitRev = appiumHelper.getGitRev();24console.log(gitRev);25const AppiumHelper = require('appium-helper');26var appiumHelper = new AppiumHelper();27var gitRev = appiumHelper.getGitRev();28console.log(gitRev);29const AppiumHelper = require('appium-helper');30var appiumHelper = new AppiumHelper();31var gitRev = appiumHelper.getGitRev();32console.log(gitRev);33const AppiumHelper = require('appium-helper');34var appiumHelper = new AppiumHelper();35var gitRev = appiumHelper.getGitRev();36console.log(gitRev);

Full Screen

Using AI Code Generation

copy

Full Screen

1var appium = require('appium');2var gitRev = appium.getGitRev();3console.log(gitRev);4var appium = require('appium');5var gitRev = appium.getGitRev();6console.log(gitRev);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful