appium 2.0.0-beta.35 → 2.0.0-beta.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/build/lib/appium.d.ts +41 -52
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +32 -15
  4. package/build/lib/cli/args.d.ts +1 -1
  5. package/build/lib/cli/args.d.ts.map +1 -1
  6. package/build/lib/cli/args.js +1 -1
  7. package/build/lib/cli/driver-command.d.ts +3 -3
  8. package/build/lib/cli/driver-command.d.ts.map +1 -1
  9. package/build/lib/cli/driver-command.js +1 -1
  10. package/build/lib/cli/extension-command.d.ts +60 -38
  11. package/build/lib/cli/extension-command.d.ts.map +1 -1
  12. package/build/lib/cli/extension-command.js +115 -59
  13. package/build/lib/cli/extension.d.ts +9 -5
  14. package/build/lib/cli/extension.d.ts.map +1 -1
  15. package/build/lib/cli/extension.js +5 -7
  16. package/build/lib/cli/parser.d.ts +3 -3
  17. package/build/lib/cli/parser.d.ts.map +1 -1
  18. package/build/lib/cli/parser.js +1 -1
  19. package/build/lib/cli/plugin-command.d.ts +1 -1
  20. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  21. package/build/lib/cli/plugin-command.js +1 -1
  22. package/build/lib/cli/utils.js +1 -1
  23. package/build/lib/config-file.d.ts.map +1 -1
  24. package/build/lib/config-file.js +1 -1
  25. package/build/lib/config.d.ts +4 -4
  26. package/build/lib/config.d.ts.map +1 -1
  27. package/build/lib/config.js +1 -1
  28. package/build/lib/constants.d.ts.map +1 -1
  29. package/build/lib/constants.js +1 -1
  30. package/build/lib/extension/driver-config.d.ts +29 -32
  31. package/build/lib/extension/driver-config.d.ts.map +1 -1
  32. package/build/lib/extension/driver-config.js +7 -20
  33. package/build/lib/extension/extension-config.d.ts +108 -36
  34. package/build/lib/extension/extension-config.d.ts.map +1 -1
  35. package/build/lib/extension/extension-config.js +199 -60
  36. package/build/lib/extension/index.d.ts +16 -7
  37. package/build/lib/extension/index.d.ts.map +1 -1
  38. package/build/lib/extension/index.js +15 -18
  39. package/build/lib/extension/manifest.d.ts +12 -12
  40. package/build/lib/extension/manifest.d.ts.map +1 -1
  41. package/build/lib/extension/manifest.js +13 -3
  42. package/build/lib/extension/package-changed.d.ts.map +1 -1
  43. package/build/lib/extension/package-changed.js +1 -1
  44. package/build/lib/extension/plugin-config.d.ts +19 -24
  45. package/build/lib/extension/plugin-config.d.ts.map +1 -1
  46. package/build/lib/extension/plugin-config.js +9 -18
  47. package/build/lib/grid-register.d.ts.map +1 -1
  48. package/build/lib/grid-register.js +1 -1
  49. package/build/lib/logger.d.ts +1 -1
  50. package/build/lib/logger.d.ts.map +1 -1
  51. package/build/lib/logger.js +1 -1
  52. package/build/lib/logsink.d.ts.map +1 -1
  53. package/build/lib/logsink.js +3 -2
  54. package/build/lib/main.d.ts +13 -12
  55. package/build/lib/main.d.ts.map +1 -1
  56. package/build/lib/main.js +4 -4
  57. package/build/lib/schema/arg-spec.d.ts +4 -4
  58. package/build/lib/schema/arg-spec.d.ts.map +1 -1
  59. package/build/lib/schema/arg-spec.js +1 -1
  60. package/build/lib/schema/cli-args.d.ts.map +1 -1
  61. package/build/lib/schema/cli-args.js +1 -1
  62. package/build/lib/schema/cli-transformers.d.ts.map +1 -1
  63. package/build/lib/schema/cli-transformers.js +1 -1
  64. package/build/lib/schema/keywords.d.ts.map +1 -1
  65. package/build/lib/schema/keywords.js +1 -1
  66. package/build/lib/schema/schema.d.ts +2 -2
  67. package/build/lib/schema/schema.d.ts.map +1 -1
  68. package/build/lib/schema/schema.js +1 -1
  69. package/build/lib/utils.d.ts.map +1 -1
  70. package/build/lib/utils.js +1 -1
  71. package/build/tsconfig.tsbuildinfo +1 -1
  72. package/build/types/appium-manifest.d.ts +23 -4
  73. package/build/types/appium-manifest.d.ts.map +1 -1
  74. package/build/types/cli.d.ts.map +1 -1
  75. package/build/types/{external-manifest.d.ts → extension-manifest.d.ts} +15 -7
  76. package/build/types/extension-manifest.d.ts.map +1 -0
  77. package/build/types/index.d.ts +6 -5
  78. package/build/types/index.d.ts.map +1 -1
  79. package/driver.d.ts +1 -0
  80. package/driver.js +14 -0
  81. package/lib/appium.js +208 -124
  82. package/lib/cli/args.js +143 -93
  83. package/lib/cli/driver-command.js +10 -15
  84. package/lib/cli/extension-command.js +226 -175
  85. package/lib/cli/extension.js +15 -19
  86. package/lib/cli/parser.js +19 -31
  87. package/lib/cli/plugin-command.js +8 -8
  88. package/lib/cli/utils.js +8 -14
  89. package/lib/config-file.js +21 -25
  90. package/lib/config.js +82 -64
  91. package/lib/constants.js +4 -13
  92. package/lib/extension/driver-config.js +171 -171
  93. package/lib/extension/extension-config.js +347 -126
  94. package/lib/extension/index.js +72 -58
  95. package/lib/extension/manifest.js +48 -57
  96. package/lib/extension/package-changed.js +9 -8
  97. package/lib/extension/plugin-config.js +62 -62
  98. package/lib/grid-register.js +29 -18
  99. package/lib/logger.js +1 -2
  100. package/lib/logsink.js +29 -31
  101. package/lib/main.js +111 -73
  102. package/lib/schema/arg-spec.js +10 -13
  103. package/lib/schema/cli-args.js +14 -37
  104. package/lib/schema/cli-transformers.js +7 -14
  105. package/lib/schema/keywords.js +15 -13
  106. package/lib/schema/schema.js +58 -75
  107. package/lib/utils.js +50 -25
  108. package/package.json +25 -18
  109. package/plugin.d.ts +1 -0
  110. package/plugin.js +13 -0
  111. package/scripts/autoinstall-extensions.js +177 -0
  112. package/support.d.ts +1 -0
  113. package/support.js +13 -0
  114. package/types/appium-manifest.ts +27 -15
  115. package/types/cli.ts +2 -9
  116. package/types/{external-manifest.ts → extension-manifest.ts} +21 -15
  117. package/types/index.ts +12 -5
  118. package/build/types/extension.d.ts +0 -43
  119. package/build/types/extension.d.ts.map +0 -1
  120. package/build/types/external-manifest.d.ts.map +0 -1
  121. package/scripts/postinstall.js +0 -71
  122. package/types/extension.ts +0 -56
@@ -1,4 +1,3 @@
1
-
2
1
  import _ from 'lodash';
3
2
  import {ExtensionConfig} from './extension-config';
4
3
  import log from '../logger';
@@ -8,7 +7,6 @@ import {PLUGIN_TYPE} from '../constants';
8
7
  * @extends {ExtensionConfig<PluginType>}
9
8
  */
10
9
  export class PluginConfig extends ExtensionConfig {
11
-
12
10
  /**
13
11
  * A mapping of {@link Manifest} instances to {@link PluginConfig} instances.
14
12
  *
@@ -19,95 +17,97 @@ export class PluginConfig extends ExtensionConfig {
19
17
  * @type {WeakMap<Manifest,PluginConfig>}
20
18
  * @private
21
19
  */
22
- static _instances = new WeakMap();
20
+ static _instances = new WeakMap();
23
21
 
24
- /**
22
+ /**
25
23
  * Call {@link PluginConfig.create} instead.
26
24
  *
27
25
  * Just calls the superclass' constructor with the correct extension type
28
26
  * @private
29
27
  * @param {Manifest} manifest - IO object
30
- * @param {PluginConfigOptions} [opts]
31
28
  */
32
- constructor (manifest, {extData, logFn} = {}) {
33
- super(PLUGIN_TYPE, manifest, logFn);
29
+ constructor(manifest) {
30
+ super(PLUGIN_TYPE, manifest);
31
+ }
34
32
 
35
- if (extData) {
36
- this.validate(extData);
37
- }
38
- }
33
+ async validate() {
34
+ return await super._validate(this.manifest.getExtensionData(PLUGIN_TYPE));
35
+ }
39
36
 
40
- /**
41
- * Creates a new {@link PluginConfig} instance for a {@link Manifest} instance.
42
- *
43
- * @param {Manifest} manifest
44
- * @param {PluginConfigOptions} [opts]
45
- * @throws If `manifest` already associated with a `PluginConfig`
46
- * @returns {PluginConfig}
47
- */
48
- static create (manifest, {extData, logFn} = {}) {
49
- const instance = new PluginConfig(manifest, {logFn, extData});
50
- if (PluginConfig.getInstance(manifest)) {
51
- throw new Error(`Manifest with APPIUM_HOME ${manifest.appiumHome} already has a PluginConfig; use PluginConfig.getInstance() to retrieve it.`);
52
- }
53
- PluginConfig._instances.set(manifest, instance);
54
- return instance;
55
- }
37
+ /**
38
+ * Creates a new {@link PluginConfig} instance for a {@link Manifest} instance.
39
+ *
40
+ * @param {Manifest} manifest
41
+ * @throws If `manifest` already associated with a `PluginConfig`
42
+ * @returns {PluginConfig}
43
+ */
44
+ static create(manifest) {
45
+ const instance = new PluginConfig(manifest);
46
+ if (PluginConfig.getInstance(manifest)) {
47
+ throw new Error(
48
+ `Manifest with APPIUM_HOME ${manifest.appiumHome} already has a PluginConfig; use PluginConfig.getInstance() to retrieve it.`
49
+ );
50
+ }
51
+ PluginConfig._instances.set(manifest, instance);
52
+ return instance;
53
+ }
56
54
 
57
- /**
58
- * Returns a PluginConfig associated with a Manifest
59
- * @param {Manifest} manifest
60
- * @returns {PluginConfig|undefined}
61
- */
62
- static getInstance (manifest) {
63
- return PluginConfig._instances.get(manifest);
64
- }
55
+ /**
56
+ * Returns a PluginConfig associated with a Manifest
57
+ * @param {Manifest} manifest
58
+ * @returns {PluginConfig|undefined}
59
+ */
60
+ static getInstance(manifest) {
61
+ return PluginConfig._instances.get(manifest);
62
+ }
65
63
 
66
- /**
64
+ /**
67
65
  * @param {string} pluginName
68
- * @param {import('../../types/appium-manifest').ExtManifest<PluginType>} pluginData
66
+ * @param {import('appium/types').ExtManifest<PluginType>} pluginData
69
67
  * @returns {string}
70
68
  */
71
- extensionDesc (pluginName, {version}) {
72
- return `${pluginName}@${version}`;
73
- }
69
+ extensionDesc(pluginName, {version}) {
70
+ return `${pluginName}@${version}`;
71
+ }
74
72
 
75
- /**
73
+ /**
76
74
  *
77
75
  * @param {(keyof PluginRecord)[]} activeNames
78
76
  * @returns {void}
79
77
  */
80
- print (activeNames) {
81
- const pluginNames = Object.keys(this.installedExtensions);
78
+ print(activeNames) {
79
+ const pluginNames = Object.keys(this.installedExtensions);
82
80
 
83
- if (_.isEmpty(pluginNames)) {
84
- log.info(`No plugins have been installed. Use the "appium plugin" ` +
85
- 'command to install the one(s) you want to use.');
86
- return;
87
- }
81
+ if (_.isEmpty(pluginNames)) {
82
+ log.info(
83
+ `No plugins have been installed. Use the "appium plugin" ` +
84
+ 'command to install the one(s) you want to use.'
85
+ );
86
+ return;
87
+ }
88
88
 
89
- log.info(`Available plugins:`);
90
- for (const [pluginName, pluginData] of _.toPairs(this.installedExtensions)) {
91
- const activeTxt = _.includes(activeNames, pluginName) ? ' (ACTIVE)' : '';
92
- log.info(` - ${this.extensionDesc(pluginName, pluginData)}${activeTxt}`);
93
- }
89
+ log.info(`Available plugins:`);
90
+ for (const [pluginName, pluginData] of _.toPairs(this.installedExtensions)) {
91
+ const activeTxt = _.includes(activeNames, pluginName) ? ' (ACTIVE)' : '';
92
+ log.info(` - ${this.extensionDesc(pluginName, pluginData)}${activeTxt}`);
93
+ }
94
94
 
95
- if (_.isEmpty(activeNames)) {
96
- log.info('No plugins activated. Use the --use-plugins flag with names of plugins to activate');
97
- }
98
- }
95
+ if (_.isEmpty(activeNames)) {
96
+ log.info(
97
+ 'No plugins activated. Use the --use-plugins flag with names of plugins to activate'
98
+ );
99
+ }
100
+ }
99
101
  }
100
102
 
101
103
  /**
102
104
  * @typedef PluginConfigOptions
103
105
  * @property {import('./extension-config').ExtensionLogFn} [logFn] - Optional logging function
104
- * @property {import('../../types/appium-manifest').PluginRecord} [extData] - Extension data
105
106
  */
106
107
 
107
-
108
108
  /**
109
- * @typedef {import('../../types/appium-manifest').PluginRecord} PluginRecord
110
- * @typedef {import('../../types').PluginType} PluginType
111
- * @typedef {import('../../types/external-manifest').ExtMetadata<PluginType>} PluginMetadata
109
+ * @typedef {import('appium/types').PluginRecord} PluginRecord
110
+ * @typedef {import('@appium/types').PluginType} PluginType
111
+ * @typedef {import('appium/types').ExtMetadata<PluginType>} PluginMetadata
112
112
  * @typedef {import('./manifest').Manifest} Manifest
113
113
  */
@@ -1,9 +1,8 @@
1
1
  import axios from 'axios';
2
- import { fs } from '@appium/support';
2
+ import {fs} from '@appium/support';
3
3
  import logger from './logger';
4
4
  import _ from 'lodash';
5
5
 
6
-
7
6
  const hubUri = (config) => {
8
7
  const protocol = config.hubProtocol || 'http';
9
8
  return `${protocol}://${config.hubHost}:${config.hubPort}`;
@@ -16,20 +15,24 @@ const hubUri = (config) => {
16
15
  * @param {number} [port] - Bind to this port
17
16
  * @param {string} [basePath] - Base path for the grid
18
17
  */
19
- async function registerNode (data, addr, port, basePath) {
18
+ async function registerNode(data, addr, port, basePath) {
20
19
  let configFilePath;
21
20
  if (_.isString(data)) {
22
21
  configFilePath = data;
23
22
  try {
24
23
  data = await fs.readFile(data, 'utf-8');
25
24
  } catch (err) {
26
- logger.error(`Unable to load node configuration file ${configFilePath} to register with grid: ${err.message}`);
25
+ logger.error(
26
+ `Unable to load node configuration file ${configFilePath} to register with grid: ${err.message}`
27
+ );
27
28
  return;
28
29
  }
29
30
  try {
30
31
  data = JSON.parse(data);
31
32
  } catch (err) {
32
- logger.errorAndThrow(`Syntax error in node configuration file ${configFilePath}: ${err.message}`);
33
+ logger.errorAndThrow(
34
+ `Syntax error in node configuration file ${configFilePath}: ${err.message}`
35
+ );
33
36
  return;
34
37
  }
35
38
  }
@@ -37,20 +40,21 @@ async function registerNode (data, addr, port, basePath) {
37
40
  postRequest(data, addr, port, basePath);
38
41
  }
39
42
 
40
- async function registerToGrid (postOptions, configHolder) {
43
+ async function registerToGrid(postOptions, configHolder) {
41
44
  try {
42
45
  const {status} = await axios(postOptions);
43
46
  if (status !== 200) {
44
47
  throw new Error(`Request failed with code ${status}`);
45
48
  }
46
- logger.debug(`Appium successfully registered with the the grid on ` +
47
- hubUri(configHolder.configuration));
49
+ logger.debug(
50
+ `Appium successfully registered with the the grid on ` + hubUri(configHolder.configuration)
51
+ );
48
52
  } catch (err) {
49
53
  logger.error(`An attempt to register with the grid was unsuccessful: ${err.message}`);
50
54
  }
51
55
  }
52
56
 
53
- function postRequest (configHolder, addr, port, basePath) {
57
+ function postRequest(configHolder, addr, port, basePath) {
54
58
  // Move Selenium 3 configuration properties to configuration object
55
59
  if (!_.has(configHolder, 'configuration')) {
56
60
  let configuration = {};
@@ -68,7 +72,11 @@ function postRequest (configHolder, addr, port, basePath) {
68
72
  // otherwise, we will take whatever the user setup
69
73
  // because we will always set localhost/127.0.0.1. this won't work if your
70
74
  // node and grid aren't in the same place
71
- if (!configHolder.configuration.url || !configHolder.configuration.host || !configHolder.configuration.port) {
75
+ if (
76
+ !configHolder.configuration.url ||
77
+ !configHolder.configuration.host ||
78
+ !configHolder.configuration.port
79
+ ) {
72
80
  configHolder.configuration.url = `http://${addr}:${port}${basePath}`;
73
81
  configHolder.configuration.host = addr;
74
82
  configHolder.configuration.port = port;
@@ -92,26 +100,30 @@ function postRequest (configHolder, addr, port, basePath) {
92
100
 
93
101
  const registerCycleInterval = configHolder.configuration.registerCycle;
94
102
  if (isNaN(registerCycleInterval) || registerCycleInterval <= 0) {
95
- logger.warn(`'registerCycle' is not a valid positive number. ` +
96
- `No registration request will be sent to the grid.`);
103
+ logger.warn(
104
+ `'registerCycle' is not a valid positive number. ` +
105
+ `No registration request will be sent to the grid.`
106
+ );
97
107
  return;
98
108
  }
99
109
  // initiate a new Thread
100
110
  let first = true;
101
- logger.debug(`Starting auto register thread for the grid. ` +
102
- `Will try to register every ${registerCycleInterval} ms.`);
103
- setInterval(async function registerRetry () {
111
+ logger.debug(
112
+ `Starting auto register thread for the grid. ` +
113
+ `Will try to register every ${registerCycleInterval} ms.`
114
+ );
115
+ setInterval(async function registerRetry() {
104
116
  if (first) {
105
117
  first = false;
106
118
  await registerToGrid(regRequest, configHolder);
107
- } else if (!await isAlreadyRegistered(configHolder)) {
119
+ } else if (!(await isAlreadyRegistered(configHolder))) {
108
120
  // make the http POST to the grid for registration
109
121
  await registerToGrid(regRequest, configHolder);
110
122
  }
111
123
  }, registerCycleInterval);
112
124
  }
113
125
 
114
- async function isAlreadyRegistered (configHolder) {
126
+ async function isAlreadyRegistered(configHolder) {
115
127
  //check if node is already registered
116
128
  const id = configHolder.configuration.id;
117
129
  try {
@@ -132,5 +144,4 @@ async function isAlreadyRegistered (configHolder) {
132
144
  }
133
145
  }
134
146
 
135
-
136
147
  export default registerNode;
package/lib/logger.js CHANGED
@@ -1,5 +1,4 @@
1
- import { logger } from '@appium/support';
2
-
1
+ import {logger} from '@appium/support';
3
2
 
4
3
  let log = logger.getLogger('Appium');
5
4
 
package/lib/logsink.js CHANGED
@@ -1,15 +1,14 @@
1
1
  import npmlog from 'npmlog';
2
- import { createLogger, format, transports } from 'winston';
3
- import { fs, logger } from '@appium/support';
2
+ import {createLogger, format, transports} from 'winston';
3
+ import {fs, logger} from '@appium/support';
4
4
  import _ from 'lodash';
5
5
 
6
-
7
6
  // set up distributed logging before everything else
8
7
  logger.patchLogger(npmlog);
9
8
  global._global_npmlog = npmlog;
10
9
 
11
10
  // npmlog is used only for emitting, we use winston for output
12
- npmlog.level = 'silent';
11
+ npmlog.level = 'info';
13
12
  const levels = {
14
13
  debug: 4,
15
14
  info: 3,
@@ -39,16 +38,13 @@ let useLocalTimeZone = false;
39
38
 
40
39
  // add the timestamp in the correct format to the log info object
41
40
  const timestampFormat = format.timestamp({
42
- format () {
41
+ format() {
43
42
  let date = new Date();
44
43
  if (useLocalTimeZone) {
45
44
  date = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
46
45
  }
47
46
  // '2012-11-04T14:51:06.157Z' -> '2012-11-04 14:51:06:157'
48
- return date.toISOString()
49
- .replace(/[TZ]/g, ' ')
50
- .replace(/\./g, ':')
51
- .trim();
47
+ return date.toISOString().replace(/[TZ]/g, ' ').replace(/\./g, ':').trim();
52
48
  },
53
49
  });
54
50
 
@@ -58,14 +54,14 @@ const colorizeFormat = format.colorize({
58
54
  });
59
55
 
60
56
  // Strip the color marking within messages
61
- const stripColorFormat = format(function stripColor (info) {
57
+ const stripColorFormat = format(function stripColor(info) {
62
58
  const code = /\u001b\[(\d+(;\d+)*)?m/g; // eslint-disable-line no-control-regex
63
59
  info.message = info.message.replace(code, '');
64
60
  return info;
65
61
  })();
66
62
 
67
- function createConsoleTransport (args, logLvl) {
68
- return new (transports.Console)({
63
+ function createConsoleTransport(args, logLvl) {
64
+ return new transports.Console({
69
65
  // `name` is unsupported per winston's type declarations
70
66
  // @ts-expect-error
71
67
  name: 'console',
@@ -75,7 +71,7 @@ function createConsoleTransport (args, logLvl) {
75
71
  level: logLvl,
76
72
  stderrLevels: ['error'],
77
73
  format: format.combine(
78
- format(function adjustDebug (info) {
74
+ format(function adjustDebug(info) {
79
75
  // prepend debug marker, and shift to `info` log level
80
76
  if (info.level === 'debug') {
81
77
  info.level = 'info';
@@ -85,15 +81,15 @@ function createConsoleTransport (args, logLvl) {
85
81
  })(),
86
82
  timestampFormat,
87
83
  args.logNoColors ? stripColorFormat : colorizeFormat,
88
- format.printf(function printInfo (info) {
84
+ format.printf(function printInfo(info) {
89
85
  return `${args.logTimestamp ? `${info.timestamp} - ` : ''}${info.message}`;
90
86
  })
91
87
  ),
92
88
  });
93
89
  }
94
90
 
95
- function createFileTransport (args, logLvl) {
96
- return new (transports.File)({
91
+ function createFileTransport(args, logLvl) {
92
+ return new transports.File({
97
93
  // @ts-expect-error
98
94
  name: 'file',
99
95
  filename: args.logFile,
@@ -105,14 +101,14 @@ function createFileTransport (args, logLvl) {
105
101
  format: format.combine(
106
102
  stripColorFormat,
107
103
  timestampFormat,
108
- format.printf(function printInfo (info) {
104
+ format.printf(function printInfo(info) {
109
105
  return `${info.timestamp} ${info.message}`;
110
106
  })
111
- )
107
+ ),
112
108
  });
113
109
  }
114
110
 
115
- function createHttpTransport (args, logLvl) {
111
+ function createHttpTransport(args, logLvl) {
116
112
  let host = '127.0.0.1';
117
113
  let port = 9003;
118
114
 
@@ -122,7 +118,7 @@ function createHttpTransport (args, logLvl) {
122
118
  port = parseInt(hostAndPort[1], 10);
123
119
  }
124
120
 
125
- return new (transports.Http)({
121
+ return new transports.Http({
126
122
  // @ts-expect-error
127
123
  name: 'http',
128
124
  host,
@@ -134,14 +130,14 @@ function createHttpTransport (args, logLvl) {
134
130
  level: logLvl,
135
131
  format: format.combine(
136
132
  stripColorFormat,
137
- format.printf(function printInfo (info) {
133
+ format.printf(function printInfo(info) {
138
134
  return `${info.timestamp} ${info.message}`;
139
135
  })
140
136
  ),
141
137
  });
142
138
  }
143
139
 
144
- async function createTransports (args) {
140
+ async function createTransports(args) {
145
141
  let transports = [];
146
142
  let consoleLogLevel = null;
147
143
  let fileLogLevel = null;
@@ -169,8 +165,9 @@ async function createTransports (args) {
169
165
  transports.push(createFileTransport(args, fileLogLevel));
170
166
  } catch (e) {
171
167
  // eslint-disable-next-line no-console
172
- console.log(`Tried to attach logging to file '${args.logFile}' but an error ` +
173
- `occurred: ${e.message}`);
168
+ console.log(
169
+ `Tried to attach logging to file '${args.logFile}' but an error ` + `occurred: ${e.message}`
170
+ );
174
171
  }
175
172
  }
176
173
 
@@ -179,15 +176,18 @@ async function createTransports (args) {
179
176
  transports.push(createHttpTransport(args, fileLogLevel));
180
177
  } catch (e) {
181
178
  // eslint-disable-next-line no-console
182
- console.log(`Tried to attach logging to Http at ${args.webhook} but ` +
183
- `an error occurred: ${e.message}`);
179
+ console.log(
180
+ `Tried to attach logging to Http at ${args.webhook} but ` +
181
+ `an error occurred: ${e.message}`
182
+ );
184
183
  }
185
184
  }
186
185
 
187
186
  return transports;
188
187
  }
189
188
 
190
- async function init (args) {
189
+ async function init(args) {
190
+ npmlog.level = 'silent';
191
191
  // set de facto param passed to timestamp function
192
192
  useLocalTimeZone = args.localTimezone;
193
193
 
@@ -211,11 +211,10 @@ async function init (args) {
211
211
  if (args.logHandler && _.isFunction(args.logHandler)) {
212
212
  args.logHandler(logObj.level, msg);
213
213
  }
214
-
215
214
  });
216
215
  }
217
216
 
218
- function clear () {
217
+ function clear() {
219
218
  if (log) {
220
219
  for (let transport of _.keys(log.transports)) {
221
220
  log.remove(transport);
@@ -224,6 +223,5 @@ function clear () {
224
223
  npmlog.removeAllListeners('log');
225
224
  }
226
225
 
227
-
228
- export { init, clear };
226
+ export {init, clear};
229
227
  export default init;