21
21
*
22
22
*/
23
23
24
- var path = require ( 'path' ) ;
25
- var fs = require ( 'fs' ) ;
24
+ const path = require ( 'path' ) ;
25
+ const fs = require ( 'fs' ) ;
26
26
27
27
module . exports = function ( context ) {
28
28
function main ( ) {
29
29
// get the file transfer server address from the specified variables
30
- var fileTransferServerAddress = getFileTransferServerAddress ( context ) || getDefaultFileTransferServerAddress ( context ) ;
30
+ const fileTransferServerAddress = getFileTransferServerAddress ( context ) || getDefaultFileTransferServerAddress ( context ) ;
31
31
console . log ( 'Tests will use the following file transfer server address: ' + fileTransferServerAddress ) ;
32
32
console . log (
33
33
'If you\'re using [email protected] and the above address is wrong at "platform add", don\'t worry, it\'ll fix itself on "cordova run" or "cordova prepare".'
@@ -38,10 +38,10 @@ module.exports = function (context) {
38
38
}
39
39
40
40
function getDefaultFileTransferServerAddress ( context ) {
41
- var address = null ;
42
- var configNodes = context . opts . plugin . pluginInfo . _et . _root . _children ;
41
+ let address = null ;
42
+ const configNodes = context . opts . plugin . pluginInfo . _et . _root . _children ;
43
43
44
- for ( var node in configNodes ) {
44
+ for ( const node in configNodes ) {
45
45
if ( configNodes [ node ] . attrib . name === 'FILETRANSFER_SERVER_ADDRESS' ) {
46
46
address = configNodes [ node ] . attrib . default ;
47
47
}
@@ -51,13 +51,13 @@ module.exports = function (context) {
51
51
}
52
52
53
53
function getFileTransferServerAddress ( context ) {
54
- var platformJsonFile = path . join (
54
+ const platformJsonFile = path . join (
55
55
context . opts . projectRoot ,
56
56
'platforms' ,
57
57
context . opts . platforms [ 0 ] ,
58
58
context . opts . platforms [ 0 ] + '.json'
59
59
) ;
60
- var platformJson = JSON . parse ( fs . readFileSync ( platformJsonFile , 'utf8' ) ) ;
60
+ const platformJson = JSON . parse ( fs . readFileSync ( platformJsonFile , 'utf8' ) ) ;
61
61
62
62
if (
63
63
platformJson &&
@@ -72,12 +72,12 @@ module.exports = function (context) {
72
72
}
73
73
74
74
function writeFileTransferOptions ( address , context ) {
75
- for ( var p in context . opts . paths ) {
76
- var ftOpts = {
75
+ for ( const p in context . opts . paths ) {
76
+ const ftOpts = {
77
77
serverAddress : address
78
78
} ;
79
- var ftOptsString = JSON . stringify ( ftOpts ) ;
80
- var ftOptsFile = path . join ( context . opts . paths [ p ] , 'fileTransferOpts.json' ) ;
79
+ const ftOptsString = JSON . stringify ( ftOpts ) ;
80
+ const ftOptsFile = path . join ( context . opts . paths [ p ] , 'fileTransferOpts.json' ) ;
81
81
fs . writeFileSync ( ftOptsFile , ftOptsString , 'utf8' ) ;
82
82
}
83
83
}
0 commit comments