From 4a8787891d322783d0d2b0d1012b13079e19f70f Mon Sep 17 00:00:00 2001 From: Crepieux Pierre Date: Tue, 1 Jun 2021 09:46:35 +0200 Subject: [PATCH] Fix code style Signed-off-by: Crepieux Pierre --- lib/cli/device/index.js | 2 +- lib/cli/provider/index.js | 2 +- lib/units/device/plugins/screen/stream.js | 6 +++--- lib/units/device/resources/minicap.js | 13 ++++++++----- lib/util/pathutil.js | 5 +++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/cli/device/index.js b/lib/cli/device/index.js index 28f1f176fa..c4e9f37022 100644 --- a/lib/cli/device/index.js +++ b/lib/cli/device/index.js @@ -98,7 +98,7 @@ module.exports.builder = function(yargs) { , default: process.env.SCREEN_JPEG_QUALITY || 80 }) .option('screen-grabber', { - describe: 'The tool to be used for screen capture. '+ + describe: 'The tool to be used for screen capture. ' + 'Value must be either: minicap-bin (default) or minicap-apk' , type: 'string' , default: process.env.SCREEN_GRABBER || 'minicap-bin' diff --git a/lib/cli/provider/index.js b/lib/cli/provider/index.js index 87f8a9e45e..e9c189ed68 100644 --- a/lib/cli/provider/index.js +++ b/lib/cli/provider/index.js @@ -117,7 +117,7 @@ module.exports.builder = function(yargs) { , default: process.env.SCREEN_JPEG_QUALITY || 80 }) .option('screen-grabber', { - describe: 'The tool to be used for screen capture. '+ + describe: 'The tool to be used for screen capture. ' + 'Value must be either: minicap-bin (default) or minicap-apk' , type: 'string' , default: process.env.SCREEN_GRABBER || 'minicap-bin' diff --git a/lib/units/device/plugins/screen/stream.js b/lib/units/device/plugins/screen/stream.js index df91bb1438..a12eadd0e9 100644 --- a/lib/units/device/plugins/screen/stream.js +++ b/lib/units/device/plugins/screen/stream.js @@ -25,7 +25,7 @@ module.exports = syrup.serial() .dependency(require('./options')) .define(function(options, adb, minicap, display, screenOptions) { var log = logger.createLogger('device:plugins:screen:stream') - log.info("ScreenGrabber option set to %s", options.screenGrabber) + log.info('ScreenGrabber option set to %s', options.screenGrabber) function FrameProducer(config, grabber) { EventEmitter.call(this) @@ -230,7 +230,7 @@ module.exports = syrup.serial() FrameProducer.prototype._startService = function() { log.info('Launching screen service %s', this.grabber) - return minicap.run(this.grabber,util.format( + return minicap.run(this.grabber, util.format( '-S -Q %d -P %s' , options.screenJpegQuality , this.frameConfig.toString() @@ -450,7 +450,7 @@ module.exports = syrup.serial() return createServer() .then(function(wss) { - log.info("creating FrameProducer: %s", options.screenGrabber) + log.info('creating FrameProducer: %s', options.screenGrabber) var frameProducer = new FrameProducer( new FrameConfig(display.properties, display.properties)) var broadcastSet = frameProducer.broadcastSet = new BroadcastSet() diff --git a/lib/units/device/resources/minicap.js b/lib/units/device/resources/minicap.js index 36fbe6e49d..2fc0c0e8c0 100644 --- a/lib/units/device/resources/minicap.js +++ b/lib/units/device/resources/minicap.js @@ -60,7 +60,8 @@ module.exports = syrup.serial() , mode: 0755 }) , apk: new Resource({ - src: pathutil.match([pathutil.module('@devicefarmer/minicap-prebuilt/prebuilt/noarch/minicap.apk')]) + src: pathutil.match([pathutil.module( + '@devicefarmer/minicap-prebuilt/prebuilt/noarch/minicap.apk')]) , dest: ['/data/local/tmp/minicap.apk'] , comm: 'minicap.apk' , mode: 0755 @@ -156,14 +157,16 @@ module.exports = syrup.serial() , resources.bin.dest , cmd ) - } else if(mode === 'minicap-apk' && resources.apk.src !== undefined ) { - runCmd = util.format( + } + else if(mode === 'minicap-apk' && resources.apk.src !== undefined) { + runCmd = util.format( 'CLASSPATH=%s app_process /system/bin io.devicefarmer.minicap.Main %s' , resources.apk.dest , cmd ) - } else { - log.error("Missing resources/unknown minicap grabber: %s", mode) + } + else { + log.error('Missing resources/unknown minicap grabber: %s', mode) } log.info(runCmd) return adb.shell(options.serial, runCmd) diff --git a/lib/util/pathutil.js b/lib/util/pathutil.js index aa6d2c40a0..79c4a687d2 100644 --- a/lib/util/pathutil.js +++ b/lib/util/pathutil.js @@ -34,10 +34,11 @@ module.exports.match = function(candidates) { // Export module.exports.requiredMatch = function(candidates) { - matched = this.match(candidates) + var matched = this.match(candidates) if(matched !== undefined) { return matched - } else { + } + else { throw new Error(util.format( 'At least one of these paths should exist: %s' , candidates.join(', ')