How to use fs.glob method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

chromedriver-specs.js

Source:chromedriver-specs.js Github

copy

Full Screen

1import { Chromedriver, getMostRecentChromedriver } from '../lib/chromedriver';2import * as utils from '../lib/utils';3import sinon from 'sinon';4import chai from 'chai';5import { fs } from 'appium-support';6import * as tp from 'teen_process';7import path from 'path';8import _ from 'lodash';9chai.should();10describe('chromedriver', function () {11 let sandbox;12 beforeEach(function () {13 sandbox = sinon.createSandbox();14 });15 afterEach(function () {16 sandbox.restore();17 });18 describe('getCompatibleChromedriver', function () {19 describe('desktop', function () {20 it('should find generic binary', async function () {21 sandbox.stub(utils, 'getChromedriverBinaryPath')22 .returns('/path/to/chromedriver');23 const cd = new Chromedriver({});24 const binPath = await cd.getCompatibleChromedriver();25 binPath.should.eql('/path/to/chromedriver');26 });27 });28 describe('Android', function () {29 let cd;30 let getChromedriverBinaryPathSpy;31 before(function () {32 cd = new Chromedriver({33 adb: {34 getApiLevel: () => 25,35 },36 });37 });38 beforeEach(function () {39 getChromedriverBinaryPathSpy = sandbox.spy(utils, 'getChromedriverBinaryPath');40 });41 afterEach(function () {42 getChromedriverBinaryPathSpy.called.should.be.false;43 });44 it('should find a compatible binary if only one binary exists', async function () {45 sandbox.stub(utils, 'getChromeVersion')46 .returns('63.0.3239.99');47 sandbox.stub(fs, 'glob')48 .returns([49 '/path/to/chromedriver',50 ]);51 sandbox.stub(tp, 'exec')52 .returns({53 stdout: 'ChromeDriver 2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',54 });55 const binPath = await cd.getCompatibleChromedriver();56 binPath.should.eql('/path/to/chromedriver');57 });58 it('should find most recent compatible binary from a number of possibilities', async function () {59 sandbox.stub(utils, 'getChromeVersion')60 .returns('59.0.3029.42');61 sandbox.stub(fs, 'glob')62 .returns([63 '/path/to/chromedriver-36',64 '/path/to/chromedriver-35',65 '/path/to/chromedriver-34',66 '/path/to/chromedriver-33',67 '/path/to/chromedriver-32',68 '/path/to/chromedriver-31',69 '/path/to/chromedriver-30',70 ]);71 sandbox.stub(tp, 'exec')72 .onCall(0)73 .returns({74 stdout: 'ChromeDriver 2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',75 })76 .onCall(0)77 .returns({78 stdout: 'ChromeDriver 2.35.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',79 })80 .onCall(0)81 .returns({82 stdout: 'ChromeDriver 2.34.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',83 })84 .onCall(0)85 .returns({86 stdout: 'ChromeDriver 2.33.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',87 })88 .onCall(0)89 .returns({90 stdout: 'ChromeDriver 2.32.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',91 })92 .onCall(0)93 .returns({94 stdout: 'ChromeDriver 2.31.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',95 })96 .onCall(0)97 .returns({98 stdout: 'ChromeDriver 2.30.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',99 });100 const binPath = await cd.getCompatibleChromedriver();101 binPath.should.eql('/path/to/chromedriver-36');102 });103 it('should correctly determine Chromedriver versions', async function () {104 sandbox.stub(fs, 'glob')105 .returns([106 '/path/to/chromedriver-36',107 '/path/to/chromedriver-35',108 '/path/to/chromedriver-34',109 '/path/to/chromedriver-33',110 '/path/to/chromedriver-32',111 '/path/to/chromedriver-31',112 '/path/to/chromedriver-30',113 ]);114 sandbox.stub(tp, 'exec')115 .onCall(0)116 .returns({117 stdout: 'ChromeDriver 2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',118 })119 .onCall(1)120 .returns({121 stdout: 'ChromeDriver 2.35.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',122 })123 .onCall(2)124 .returns({125 stdout: 'ChromeDriver 2.34.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',126 })127 .onCall(3)128 .returns({129 stdout: 'ChromeDriver 2.33.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',130 })131 .onCall(4)132 .returns({133 stdout: 'ChromeDriver 2.32.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',134 })135 .onCall(5)136 .returns({137 stdout: 'ChromeDriver 2.31.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',138 })139 .onCall(6)140 .returns({141 stdout: 'ChromeDriver 2.30.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',142 });143 const chromedrivers = await cd.getChromedrivers({});144 for (const [cd, expectedVersion] of _.zip(chromedrivers, ['2.36', '2.35', '2.34', '2.33', '2.32', '2.31', '2.30'])) {145 cd.version.should.eql(expectedVersion);146 }147 });148 it('should find most recent binary from a number of possibilities when chrome is too new', async function () {149 sandbox.stub(utils, 'getChromeVersion')150 .returns('70.0.0.42');151 sandbox.stub(fs, 'glob')152 .returns([153 '/path/to/chromedriver-9000',154 '/path/to/chromedriver-8999',155 '/path/to/chromedriver-36',156 '/path/to/chromedriver-35',157 ]);158 sandbox.stub(tp, 'exec')159 .onCall(0)160 .returns({161 stdout: 'ChromeDriver 2.9000.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',162 })163 .onCall(0)164 .returns({165 stdout: 'ChromeDriver 2.8999.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',166 })167 .onCall(0)168 .returns({169 stdout: 'ChromeDriver 2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',170 })171 .onCall(0)172 .returns({173 stdout: 'ChromeDriver 2.35.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',174 });175 const binPath = await cd.getCompatibleChromedriver();176 binPath.should.eql('/path/to/chromedriver-9000');177 });178 it('should search specified directory if provided', async function () {179 const cd = new Chromedriver({180 adb: {181 getApiLevel: () => 25,182 },183 executableDir: '/some/local/dir/for/chromedrivers',184 });185 sandbox.stub(utils, 'getChromeVersion')186 .returns('63.0.3239.99');187 sandbox.stub(fs, 'glob')188 .withArgs('/some/local/dir/for/chromedrivers/*')189 .returns([190 '/some/local/dir/for/chromedrivers/chromedriver',191 ]);192 sandbox.stub(tp, 'exec')193 .returns({194 stdout: 'ChromeDriver 2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',195 });196 const binPath = await cd.getCompatibleChromedriver();197 binPath.should.eql('/some/local/dir/for/chromedrivers/chromedriver');198 });199 it('should use alternative mapping if provided', async function () {200 const cd = new Chromedriver({201 adb: {202 getApiLevel: () => 25,203 },204 mappingPath: path.resolve(__dirname, '..', '..', 'test', 'fixtures', 'alt-mapping.json'),205 });206 sandbox.stub(utils, 'getChromeVersion')207 .returns('63.0.3239.99');208 sandbox.stub(fs, 'glob')209 .returns([210 '/path/to/chromedriver-42',211 ]);212 sandbox.stub(tp, 'exec')213 .returns({214 stdout: 'ChromeDriver 2.42.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',215 });216 const binPath = await cd.getCompatibleChromedriver();217 binPath.should.eql('/path/to/chromedriver-42');218 });219 it('should use alternative mapping if provided even if semver is broken', async function () {220 const cd = new Chromedriver({221 adb: {222 getApiLevel: () => 25,223 },224 mappingPath: path.resolve(__dirname, '..', '..', 'test', 'fixtures', 'alt-mapping-nonsemver.json'),225 });226 sandbox.stub(utils, 'getChromeVersion')227 .returns('63.0.3239.99');228 sandbox.stub(fs, 'glob')229 .returns([230 '/path/to/chromedriver-42',231 ]);232 sandbox.stub(tp, 'exec')233 .returns({234 stdout: 'ChromeDriver 2.42.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8)',235 });236 const binPath = await cd.getCompatibleChromedriver();237 binPath.should.eql('/path/to/chromedriver-42');238 });239 });240 });241 describe('getMostRecentChromedriver', function () {242 it('should get a value by default', function () {243 getMostRecentChromedriver().should.be.a.string;244 });245 it('should get the most recent version', function () {246 const mapping = {247 '2.12': '36.0.1985',248 '2.11': '36.0.1985',249 '2.10': '33.0.1751',250 '2.9': '31.0.1650',251 '2.8': '30.0.1573',252 '2.7': '30.0.1573',253 '2.6': '29.0.1545',254 };255 getMostRecentChromedriver(mapping).should.eql('2.12');256 });257 it('should handle broken semver', function () {258 const mapping = {259 '2.12': '36.0.1985',260 'v2.11': '36.0.1985',261 '2.10.0.0': '33.0.1751',262 '2.9-beta': '31.0.1650',263 '2.8': '30.0.1573',264 '2.7': '30.0.1573',265 '2.6': '29.0.1545',266 };267 getMostRecentChromedriver(mapping).should.eql('2.12');268 });269 it('should fail for empty mapping', function () {270 (() => getMostRecentChromedriver({}))271 .should.throw('Unable to get most recent Chromedriver from empty mapping');272 });273 });...

Full Screen

Full Screen

service.js

Source:service.js Github

copy

Full Screen

...33 if (nameDefault !== undefined) {34 var mediaPath = settings.hsPath('Media', obj.menu, 'Images', 'Artwork');35 // for each artwork folder (1,2,3,4)36 for (var i = 1; i <= 4; i++) { (function (i) {37 fs.glob(nameDefault+'.*', {cwd: mediaPath+i}).then(function(files) {38 if (files && files.length > 0) {39 obj.artworks['artwork'+i] = fs.join(mediaPath+i, files[0]);40 dataServer.serveFile['Artwork'+i+'.'+fs.extname(files[0])] = obj.artworks['artwork'+i];41 }42 });43 })(i);}44 }45 // Look for video in $HSROOT/Media/$MENU/Video/$NAME.*46 var vidPath = settings.hsPath('Media', menu, 'Video');47 var videoName = name;48 // if this is a default theme, change look path for video49 if (nameDefault !== undefined) {50 videoName = nameDefault;51 }52 fs.glob(videoName+'.*', {cwd: vidPath}).then(function(files) {53 if (files && files.length !== 0) {54 obj.video = fs.join(vidPath, files[0]);55 dataServer.serveFile['Video.mp4'] = obj.video;56 dataServer.serveFile[files[0]] = obj.video;57 }58 obj.html = htmlPath;59 });60 service.curType = 'html';61 return obj;62 }63 // Else this is a standard HS Theme64 var ownFiles = {};65 // Glob to list theme files66 fs.glob('**/*', {cwd: obj.path}).then(function(files) {67 registerFiles(obj.path, files, ownFiles);68 // Parse Theme.xml manifest69 return xml.parse(ownFiles.Theme);70 }).then(function(data) {71 obj.manifest = data.Theme;72 // Find default theme artworks if exists73 if (nameDefault !== undefined) {74 var mediaPath = settings.hsPath('Media', obj.menu, 'Images', 'Artwork');75 // for each artwork folder (1,2,3,4)76 for (var i = 1; i <= 4; i++) { (function (i) {77 fs.glob(nameDefault+'.*', {cwd: mediaPath+i}).then(function(files) {78 if (files && files.length > 0) {79 obj.artworks['artwork'+i] = fs.join(mediaPath+i, files[0]);80 }81 });82 })(i);}83 }84 // Find artworks file paths85 if (obj.manifest.artwork1 && ownFiles.Artwork1)86 obj.artworks.artwork1 = ownFiles.Artwork1;87 if (obj.manifest.artwork2 && ownFiles.Artwork2)88 obj.artworks.artwork2 = ownFiles.Artwork2;89 if (obj.manifest.artwork3 && ownFiles.Artwork3)90 obj.artworks.artwork3 = ownFiles.Artwork3;91 if (obj.manifest.artwork4 && ownFiles.Artwork4)92 obj.artworks.artwork4 = ownFiles.Artwork4;93 // Find background file path94 if (ownFiles.Background) {95 obj.background = ownFiles.Background;96 }97 // Find overlay file path98 if (obj.manifest.video && ownFiles.Video) {99 obj.overlay = ownFiles.Video;100 }101 // Look for video in $HSROOT/Media/$MENU/Video/$NAME.*102 if (obj.manifest.video) {103 var path = settings.hsPath('Media', obj.menu, 'Video');104 var videoName = obj.name;105 // if this is a default theme, change look path for video106 if (nameDefault !== undefined) {107 videoName = nameDefault;108 }109 fs.glob(videoName+'.*', {cwd: path}).then(function(files) {110 if (files && files.length > 0) {111 obj.video = fs.join(path, files[0]);112 } else {113 obj.video = service.defaultVideo;114 }115 });116 }117 });118 service.curType = 'hs';119 return obj;120 };121 /***************************** default video ******************************/122 // Look for the global default at %HS_PATH%/Media/Frontend/Video/No Video.(flv|mp4)123 service.defaultVideo = '';124 var path = settings.hsPath('Media', 'Frontend', 'Video');125 fs.glob('No Video*', {cwd: path}).then(function(files) {126 if (files && files.length !== 0)127 service.defaultVideo = fs.join(path, files[0]);128 });129 console.log('themes - ready');130 return service;131 }...

Full Screen

Full Screen

customerFactory_test.js

Source:customerFactory_test.js Github

copy

Full Screen

1var should = require('should');2var path = require('path');3module.exports = {4 before: function () {5 global.glob = {6 factories: require('../factories'),7 config: require('../config'),8 modules: {fs: require('./mocks/fs').create({'fake': {'contacts.csv': 2}})},9 service:require('../service'),10 mocks: {11 fs: require('./mocks/fs')12 }13 }14 glob.modules.debitoor = require('debitoor')(glob.config.app.app_token);15 glob.mockGoogleCsv = ['Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Group Membership,E-mail 1 - Type,E-mail 1 - Value,Phone 1 - Type,Phone 1 - Value,Address 1 - Type,Address 1 - Formatted,Address 1 - Street,Address 1 - City,Address 1 - PO Box,Address 1 - Region,Address 1 - Postal Code,Address 1 - Country,Address 1 - Extended Address,Website 1 - Type,Website 1 - Value',16 'Автомотозип,Автомотозип,,,,,,,,,,,,,,,,,,,,,,,,,* My Contacts,,,Mobile,+380961386500,Home,"Украина, Харьков, ул. Пушкинская,43","ул. Пушкинская,43",Харьков,,,,Украина,,Profile,automotozip.ua',17 'Алексей мото мастер,Алексей мото мастер,,,,,,,,,,,,,,,,,,,,,,,,,* My Contacts,,,Mobile,0636295078,,,,,,,,,,,',18 'Алексей такси,Алексей такси,,,,,,,,,,,,,,,,,,,,,,,,,* My Contacts,,,Mobile,0636303553,,,,,,,,,,,',19 'Андрюха водолага,Андрюха водолага,,,,,,,,,,,,,,,,,,,,,,,,,* My Contacts,,,Mobile,+380990274552,,,,,,,,,,,',20 'Валерий Черепанов,Валерий,,Черепанов,,,,,,,,Троллера,,,,,,,,,,,,,,,* My Contacts,,,Mobile,0632732034,,,,,,,,,,,'].join('\n');21 glob.modules.fs.writeFile('fake/contacts.csv', glob.mockGoogleCsv, function (err, file) {22 });23 },24 customerFactory: {25 '#getCustomerFrom()': {26 'should return customer from google contact': function () {27 var mockObject = {28 name: "Joe",29 'address 1 - formatted': "Joe street,4",30 'phone 1 - value': '123456789',31 'e-mail 1 - value': 'joe@joe.com',32 'website 1 - value': 'http://example.com',33 'address 1 - country': 'Ukraine'34 }35 console.log('we are at getCustomer from');36 var customer = glob.factories.customer.getCustomerFrom(mockObject, 'googleContact');37 customer.name.should.equal('Joe');38 customer.address.should.equal('Joe street,4');39 customer.phone.should.equal('123456789');40 customer.homepage.should.equal('http://example.com');41 customer.countryName.should.equal('Ukraine');42 }43 },44 '#getCustomersFrom()': {45 'should return array customers from': function () {46 var mockObjects = [47 {48 name: "Joe",49 'address 1 - formatted': "Joe street,4",50 'phone 1 - value': '123456789',51 'e-mail 1 - value': 'joe@joe.com',52 'website 1 - value': 'http://example.com',53 'address 1 - country': 'Ukraine'54 },55 {56 name: "Joe2",57 'address 1 - formatted': "Joe street,5",58 'phone 1 - value': '123456789',59 'e-mail 1 - value': 'joe@joe.com',60 'website 1 - value': 'http://example.com',61 'address 1 - country': 'Ukraine'62 },63 {64 name: "Joe3",65 'address 1 - formatted': "Joe street,6",66 'phone 1 - value': '123456789',67 'e-mail 1 - value': 'joe@joe.com',68 'website 1 - value': 'http://example.com',69 'address 1 - country': 'Ukraine'70 }71 ]72 var customers = glob.factories.customer.getCustomersFrom(mockObjects, 'googleContact');73 customers.length.should.equal(3);74 }75 },76 '#getCustomersFromGoogleCsv()': {77 'should read csvFile and return json formatted customers': function (done) {78 var fs = glob.modules.fs;79 glob.factories.customer.getCustomersFromGoogleCsv('fake/contacts.csv', function (err, contents) {80 console.log('contents:', contents);81 should.not.exist(err);82 contents.length.should.equal(5);83 done();84 });85 }86 }87 }...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1const MemoryFileSystem = require("memory-fs");2const { test } = require("tap");3const { prepare } = require(".");4test("defaults", (t) => {5 const files = {6 "version.js": Buffer.from("module.exports = '0.0.0-development'"),7 };8 const fs = new MemoryFileSystem(files);9 prepare(10 {11 fs,12 glob: {13 sync() {14 return ["/version.js"];15 },16 },17 },18 {19 cwd: "",20 nextRelease: {21 version: "1.2.3",22 },23 logger: {24 error: (message) => t.fail(message),25 log() {},26 success() {},27 },28 }29 );30 const newContent = fs.readFileSync("/version.js", "utf8");31 t.match(newContent, /1.2.3/, "Version updated in /version.js");32 t.end();33});34test("no file matches", (t) => {35 try {36 prepare(37 {38 files: ["DOES_NOT_EXIST.nope"],39 },40 {41 cwd: "",42 nextRelease: {43 version: "1.2.3",44 },45 logger: {46 error: (message) => t.fail(message),47 log() {},48 success() {},49 },50 }51 );52 t.fail("Should throw error");53 } catch (error) {54 t.is(error.message, 'No file matches for ["DOES_NOT_EXIST.nope"]');55 }56 t.end();57});58test("files: 'README.md'", (t) => {59 const files = {60 "README.md": Buffer.from(`# my-project61current version: 0.0.0-development`),62 };63 const fs = new MemoryFileSystem(files);64 prepare(65 {66 files: "README.md",67 fs,68 glob: {69 sync() {70 return ["/README.md"];71 },72 },73 },74 {75 cwd: "",76 nextRelease: {77 version: "1.2.3",78 },79 logger: {80 error: (message) => t.fail(message),81 log() {},82 success() {},83 },84 }85 );86 const newContent = fs.readFileSync("/README.md", "utf8");87 t.match(newContent, /1.2.3/, "Version updated in README.md");88 t.end();89});90test('multiple files: ["README.md", "my-app.js"]', (t) => {91 const files = {92 "README.md": Buffer.from(`# my-project93current version: 0.0.0-development`),94 "my-app.js": Buffer.from(`module.exports.version = "0.0.0-development";`),95 };96 const fs = new MemoryFileSystem(files);97 prepare(98 {99 files: "README.md",100 fs,101 glob: {102 sync() {103 return ["/README.md", "/my-app.js"];104 },105 },106 },107 {108 cwd: "",109 nextRelease: {110 version: "1.2.3",111 },112 logger: {113 error: (message) => t.fail(message),114 log() {},115 success() {},116 },117 }118 );119 t.match(120 fs.readFileSync("/README.md", "utf8"),121 /1.2.3/,122 "Version updated in README.md"123 );124 t.match(125 fs.readFileSync("/my-app.js", "utf8"),126 /1.2.3/,127 "Version updated in my-app.js"128 );129 t.end();130});131test("version not found", (t) => {132 const files = {133 "foo.js": Buffer.from(`module.exports = require("./bar");`),134 "bar.js": Buffer.from(`module.exports.version = "0.0.0-development";`),135 };136 const fs = new MemoryFileSystem(files);137 prepare(138 {139 files: "*",140 fs,141 glob: {142 sync() {143 return ["/foo.js", "/bar.js"];144 },145 },146 },147 {148 cwd: "",149 nextRelease: {150 version: "1.2.3",151 },152 logger: {153 error: (message) => t.fail(message),154 log() {},155 success() {},156 },157 }158 );159 t.match(160 fs.readFileSync("/bar.js", "utf8"),161 /1.2.3/,162 "Version updated in bar.js"163 );164 t.end();165});166test("multiple matches in same file", (t) => {167 const files = {168 "app.js": Buffer.from(`module.exports.version = "0.0.0-development";169module.exports.logVersion = () => console.log("0.0.0-development");`),170 };171 const fs = new MemoryFileSystem(files);172 prepare(173 {174 fs,175 glob: {176 sync() {177 return ["/app.js"];178 },179 },180 },181 {182 cwd: "",183 nextRelease: {184 version: "1.2.3",185 },186 logger: {187 error: (message) => t.fail(message),188 log() {},189 success() {},190 },191 }192 );193 const newContent = fs.readFileSync("/app.js", "utf8");194 t.equals(195 newContent,196 `module.exports.version = "1.2.3";197module.exports.logVersion = () => console.log("1.2.3");`198 );199 t.end();200});201test("custom search", (t) => {202 const files = {203 "version.js": Buffer.from("module.exports = '{{VERSION}}'"),204 };205 const fs = new MemoryFileSystem(files);206 prepare(207 {208 placeholder: "{{VERSION}}",209 fs,210 glob: {211 sync() {212 return ["/version.js"];213 },214 },215 },216 {217 cwd: "",218 nextRelease: {219 version: "1.2.3",220 },221 logger: {222 error: (message) => t.fail(message),223 log() {},224 success() {},225 },226 }227 );228 const newContent = fs.readFileSync("/version.js", "utf8");229 t.match(newContent, /1.2.3/, "Version updated in /version.js");230 t.end();...

Full Screen

Full Screen

fileLister.js

Source:fileLister.js Github

copy

Full Screen

1const fileLister = function(path, fs, glob, mkdirp, tar) {2 this.path = path;3 this.fs = fs;4 this.glob = glob;5 this.mkdirp = mkdirp;6 this.tar = tar;7};89fileLister.prototype.extractTar = function(dir, buffer) {10 let name = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 5);11 return this.writeFile(process.cwd(), `${name}.tar`, buffer).then(() => {12 return this.ensureDir(dir);13 }).then(() => {14 return this.tar.x({15 file : this.path.join(process.cwd(), `${name}.tar`),16 cwd : this.path.join(process.cwd(), dir)17 });18 }).then(() => {19 return this.deleteFile(process.cwd(), `${name}.tar`);20 })21};2223fileLister.prototype.tarDir = function(dir) {24 let name = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 5);25 let data = null;2627 return this.ensureDir(dir).then(() => {28 return this.tar.c({29 gzip : false,30 file : `${name}.tar`,31 cwd : this.path.join(process.cwd(), dir)32 }, [33 "."34 ]);35 }).then(() => {36 // read the tarball and return it37 return this.readFile(process.cwd(), `${name}.tar`, true);38 }).then((buffer) => {39 data = buffer;40 return this.deleteFile(process.cwd(), `${name}.tar`);41 }).then(() => {42 return Promise.resolve(data);43 })44};4546fileLister.prototype.executeGlob = function(lookup) {47 return new Promise((resolve, reject) => {48 this.glob(lookup, (err, results) => {49 if (err) {50 return reject(err);51 }5253 return resolve(results.map((f) => {54 return {55 path : f,56 basename : this.path.basename(f),57 name : this.path.basename(f).split(".").slice(0, -1).join(".")58 }59 }));60 });61 });62};6364fileLister.prototype.readFile = function(dir, file, binary) {65 return new Promise((resolve, reject) => {66 this.ensureDir(dir).then(() => {67 this.fs.readFile(this.path.join(dir, file), (err, content) => {68 if (err) {69 return reject(err);70 }7172 if (binary) {73 return resolve(content);74 }7576 return resolve(content.toString("utf8"));77 });78 });79 });80};8182fileLister.prototype.readJSONFile = function(dir, file) {83 return new Promise((resolve, reject) => {84 this.ensureDir(dir).then(() => {85 this.fs.readFile(this.path.join(dir, file), (err, content) => {86 if (err) {87 return reject(err);88 }8990 let data = null;91 try {92 data = JSON.parse(content);93 } catch(e) {94 console.error(`Failed to parse file ${file} in ${dir}`);95 }9697 if (data === null) {98 return reject(new Error(`Cannot parse file ${file} in ${dir}`));99 }100101 return resolve(data);102 });103 });104 });105};106107fileLister.prototype.ensureDir = function(dir) {108 return this.mkdirp(dir);109};110111fileLister.prototype.writeFile = function(dir, file, contents) {112 return new Promise((resolve, reject) => {113 this.ensureDir(dir).then(() => {114 this.fs.writeFile(this.path.join(dir, file), contents, (err) => {115 if (err) {116 return reject(err);117 }118119 return resolve();120 });121 });122 });123};124125fileLister.prototype.deleteFile = function(dir, file) {126 return new Promise((resolve, reject) => {127 this.ensureDir(dir).then(() => {128 this.fs.unlink(this.path.join(dir, file), (err) => {129 if (err) {130 return reject(err);131 }132133 return resolve();134 });135 });136 });137};138139module.exports = function(path, fs, glob, mkdirp, tar) {140 if (!path) {141 path = require("path");142 }143144 if (!fs) {145 fs = require("fs");146 }147148 if (!glob) {149 glob = require("glob");150 }151152 if (!mkdirp) {153 mkdirp = require("mkdirp");154 }155156 if (!tar) {157 tar = require('tar');158 }159160 return new fileLister(path, fs, glob, mkdirp, tar); ...

Full Screen

Full Screen

xtcWS.js

Source:xtcWS.js Github

copy

Full Screen

...74//~ console.log('returning', files);75 return files;76};77//~ fs.mimeImages = function() {78 //~ return fs.glob(__dirname+'/public/imgs');79//~ };80//~ console.log( fs.mimeImages() );81process.on('message', function(m, skt) {82 if ( typeof(m)!='object' ) return;83//~ console.log('WS-Client>>> ',m);84 switch(m.o) {85 case 'term':86 if ( !term ) launch_terminal();87 if ( m.d ) term.write(m.d);88 break;89 case 'term-resize':90 if (term) term.resize(m.d.cols, m.d.rows);91 break;92 case 'js':...

Full Screen

Full Screen

read-rc.js

Source:read-rc.js Github

copy

Full Screen

1import fs from 'fs'2import path from 'path'3import Hjson from 'hjson'4import fg from 'fast-glob'5export default class ReadRC {6 constructor (props = {}) {7 this.fileNames = [ '.bscpmrc', '.bscpmrc.json' ]8 this.contextRoot = props.contextRoot || process.cwd()9 this.fsGlobOps = { 'onlyDirectories': true }10 }11 toJSON () {12 let packInfo = this.extractRCFromPakcage()13 let rc = {}14 for (let filename of this.fileNames) {15 if (fs.existsSync(`${this.contextRoot}/${filename}`)) {16 rc = Hjson.parse(fs.readFileSync(`${this.contextRoot}/${filename}`, 'utf-8'))17 break18 }19 }20 return Object.assign({}, packInfo, rc)21 }22 get (key) {23 return this.toJSON()[key]24 }25 getLocalModulesPath () {26 const libsPath = this.getLibsPath(false)27 return libsPath.map(p => path.join(this.contextRoot, p))28 }29 /*30 filter private module31 */32 getPublishModulesPath (absolute = true) {33 const libsPath = this.getLibsPath(false)34 const totalPMPaths = fg.sync([ ...this.get('privates') ], this.fsGlobOps).join(' ')35 const paths = libsPath.filter(cp => !totalPMPaths.match(new RegExp(cp), 'ig'))36 if (absolute) {37 return paths.map(p => path.join(this.contextRoot, p))38 }39 return paths40 }41 getComponentsPath (absolute = true) {42 const paths = fg.sync(this.toJSON().components, this.fsGlobOps)43 if (absolute) {44 return paths.map(p => path.join(this.contextRoot, p))45 }46 return paths47 }48 getLibsPath (absolute = true) {49 const { components, libs } = this.toJSON()50 const libsPath = new Set(libs.concat(components))51 const paths = fg.sync([ ...libsPath ], this.fsGlobOps)52 if (absolute) {53 return paths.map(p => path.join(this.contextRoot, p))54 }55 return paths56 }57 getPackageInfo () {58 return fs.existsSync(`${this.contextRoot}/package.json`) &&59 require(`${this.contextRoot}/package.json`) || {}60 }61 extractRCFromPakcage () {62 const { maintainers = [], name, description } = this.getPackageInfo()63 const developers = maintainers.map(developer => developer.name)64 return {65 'name': name,66 'module': name,67 'description': description,68 'developers': developers, // TODO: remove69 'team': 'Unknown',70 'components': [], // fs-glob71 'libs': [], // fs-glob72 'privates': [], // fs-glob73 'lifecycle': { // hooks74 'prebuildOnly': '', // trigger when component build static75 'postbuild': '' // after all module build76 },77 'category': '',78 'device': '',79 'mock': {80 'https': ''81 }82 }83 }...

Full Screen

Full Screen

glob-util.js

Source:glob-util.js Github

copy

Full Screen

1import minimatch from 'minimatch';2import capture from 'minimatch-capture';3import { List } from 'immutable';4const GLOB_OPTIONS = {dot: true};5export const glob = (str, globPattern) => {6 return minimatch(str, globPattern, GLOB_OPTIONS);7};8export const globSeq = (seq, globPattern) => {9 return seq.filter((path) => minimatch(path, globPattern, GLOB_OPTIONS));10};11export const globPaths = (fs, globPattern) => {12 return globSeq(fs.keySeq(), globPattern);13};14export const captureGlobPaths = (fs, globPattern, filterCondition = (path) => true) => {15 return fs.keySeq().reduce((captures, path) => {16 if (filterCondition(path)) {17 const pathCaptures = capture(path, globPattern, GLOB_OPTIONS);18 if (pathCaptures) {19 return captures.concat(pathCaptures);20 }21 }22 return captures;23 }, List());...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const path = require('path');3const fs = require('fs');4const chai = require('chai');5const chaiAsPromised = require('chai-as-promised');6chai.use(chaiAsPromised);7chai.should();8const { exec } = require('child_process');9const host = 'localhost';10const port = 4723;11const desiredCaps = {12 app: path.resolve(__dirname, 'test.app'),13};14const driver = wd.promiseChainRemote(url);15driver.init(desiredCaps);16 .glob('**/*.png')17 .then((files) => {18 files.forEach((file) => {19 console.log(file);20 });21 })22 .finally(() => {23 driver.quit();24 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .then(function () {9 return client.execute('mobile: glob', {pattern: '/private/var/mobile/Containers/Data/Application/*/Documents/*'});10 })11 .then(function (res) {12 console.log(res);13 })14 .end();15{ state: 'success',

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var glob = require('glob');3fs.glob = function(pattern, cb) {4 glob(pattern, cb);5};6module.exports = fs;7var fs = require('fs');8var glob = require('glob');9fs.glob = function(pattern, cb) {10 glob(pattern, cb);11};12module.exports = fs;13var fs = require('fs');14var glob = require('glob');15fs.glob = function(pattern, cb) {16 glob(pattern, cb);17};18module.exports = fs;19var fs = require('fs');20var glob = require('glob');21fs.glob = function(pattern, cb) {22 glob(pattern, cb);23};24module.exports = fs;25var fs = require('fs');26var glob = require('glob');27fs.glob = function(pattern, cb) {28 glob(pattern, cb);29};30module.exports = fs;31var fs = require('fs');32var glob = require('glob');33fs.glob = function(pattern, cb) {34 glob(pattern, cb);35};36module.exports = fs;37var fs = require('fs');38var glob = require('glob');39fs.glob = function(pattern, cb) {40 glob(pattern, cb);41};42module.exports = fs;43var fs = require('fs');44var glob = require('glob');45fs.glob = function(pattern, cb) {46 glob(pattern, cb);47};48module.exports = fs;49var fs = require('fs');50var glob = require('glob');51fs.glob = function(pattern, cb) {52 glob(pattern, cb);53};54module.exports = fs;

Full Screen

Using AI Code Generation

copy

Full Screen

1var glob = require('glob');2var path = require('path');3var fs = require('fs');4var appPath = glob.sync(path.resolve(process.cwd(), 'build/Release-iphonesimulator/*.app'))[0];5var app = fs.readFileSync(appPath);6console.log(appPath);7var glob = require('glob');8var path = require('path');9var fs = require('fs');10var appPath = glob.sync(path.resolve(process.cwd(), 'build/Release-iphonesimulator/*.app'))[0];11var app = fs.readFileSync(appPath);12console.log(appPath);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('chai').assert;3var fs = require('fs');4var path = require('path');5var desired = {6};7var driver = wd.promiseChainRemote("localhost", 4723);8driver.init(desired).then(function () {9 return driver.glob("Library/AddressBook/AddressBook.sqlitedb");10}).then(function (files) {11 console.log(files);12 return driver.quit();13});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fs } from 'appium-xcuitest-driver';2const glob = await fs.glob('globPattern', 'pathToSearch', 'opts');3console.log(glob);4const glob = await fs.glob('*.app', '/var/mobile/Containers/Data/Application');5console.log(glob);6import { fs } from 'appium-xcuitest-driver';7const which = await fs.which('fileName', 'opts');8console.log(which);9const which = await fs.which('WebDriverAgentRunner-Runner.app', {timeout: 10000});10console.log(which);11import { fs } from 'appium-xcuitest-driver';12const mv = await fs.mv('source', 'destination

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2let files = fs.glob('/Users/myname/Desktop/MyApp/MyAppUITests/*.swift');3let swiftFiles = files.filter((file) => {4 return file.endsWith('.swift');5});6console.log(swiftFiles);7const fs = require('fs');8let files = fs.glob('/Users/myname/Desktop/MyApp/MyAppUITests/*.swift');9let swiftFiles = files.filter((file) => {10 return file.endsWith('.swift');11});12console.log(swiftFiles);13const fs = require('fs');14let files = fs.glob('/Users/myname/Desktop/MyApp/MyAppUITests/*.swift');15let swiftFiles = files.filter((file) => {16 return file.endsWith('.swift');17});18console.log(swiftFiles);19const fs = require('fs');20let files = fs.glob('/Users/myname/Desktop/MyApp/MyAppUITests/*.swift');21let swiftFiles = files.filter((file) => {22 return file.endsWith('.swift

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 Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful