@@ -18,28 +18,23 @@ function openVisualStudioProject (visualStudioFilePath, callback) {
18
18
. nodeify ( callback ) ;
19
19
}
20
20
21
- // searches for the telemetry file present in every platform project
22
21
function searchForTelemetryFile ( dir ) {
23
22
var telemetryFile = path . join ( dir , constants . TELEMETRY_FILE_NAME ) ;
24
23
return Q . nfcall ( fs . stat , telemetryFile ) . then ( function ( info ) {
25
- // return current directory if the name matches and it's a file
26
24
if ( info . isFile ( ) ) {
27
25
return dir ;
28
26
}
29
27
} )
30
28
. catch ( function ( err ) {
31
- // report any error other than not found
32
29
if ( err . code !== 'ENOENT' ) {
33
30
throw err ;
34
31
}
35
32
} )
36
33
. then ( function ( root ) {
37
- // if a result was found, return it
38
34
if ( root ) {
39
35
return root ;
40
36
}
41
37
42
- // search parent directory unless we are already at the root
43
38
var parentPath = path . resolve ( dir , '..' ) ;
44
39
if ( parentPath !== dir ) {
45
40
return searchForTelemetryFile ( parentPath ) ;
@@ -48,13 +43,9 @@ function searchForTelemetryFile (dir) {
48
43
}
49
44
50
45
function isProjectRoot ( dir ) {
51
- // get available app categories
52
46
var appTypes = [ constants . PWA_FOLDER , constants . POLYFILLS_FOLDER ] ;
53
-
54
- // get available platform IDs
55
47
var platforms = platformTools . listPlatforms ( ) ;
56
48
57
- // search child platform folders
58
49
return Q . nfcall ( fs . readdir , dir ) . then ( function ( files ) {
59
50
var searchTasks = files . map ( function ( file ) {
60
51
@@ -68,7 +59,6 @@ function isProjectRoot (dir) {
68
59
return Q . resolve ( false ) ;
69
60
}
70
61
71
- // search for telemetry file in the platform folder
72
62
var platformDir = path . join ( dir , file ) ;
73
63
return searchForTelemetryFile ( platformDir ) . then ( function ( result ) {
74
64
return result ;
@@ -84,23 +74,19 @@ function isProjectRoot (dir) {
84
74
} ) ;
85
75
}
86
76
87
- // given a path within a pwabuilder project, returns its root
88
77
function getProjectRoot ( dir ) {
89
78
var insidePWA = new RegExp ( constants . PWA_FOLDER + '$' ) ;
90
79
var insidePolyfills = new RegExp ( constants . POLYFILLS_FOLDER + '$' ) ;
91
80
92
- // check if this is the project root
93
81
return isProjectRoot ( dir ) . then ( function ( isRoot ) {
94
82
if ( isRoot ) {
95
83
return dir ;
96
84
} else if ( dir . match ( insidePWA ) || dir . match ( insidePolyfills ) ) {
97
85
return getProjectRoot ( path . resolve ( dir , '..' ) ) ;
98
86
}
99
87
100
- // search for a platform folder containing telemetry file
101
88
return searchForTelemetryFile ( dir ) . then ( function ( filePath ) {
102
89
if ( filePath ) {
103
- // start search for project root from the platform folder
104
90
var parentPath = path . resolve ( filePath , '..' ) ;
105
91
if ( parentPath !== dir ) {
106
92
return getProjectRoot ( parentPath ) ;
@@ -125,7 +111,6 @@ function getProjectRoot (dir) {
125
111
function getProjectPlatformsRecursivelly ( dir , configuredPlatforms , foundPlatforms ) {
126
112
if ( ! foundPlatforms ) { foundPlatforms = [ ] ; }
127
113
128
- // search recursivelly for telemetry files or known platform folders with telemetry matching info inside
129
114
return Q . nfcall ( fs . readdir , dir ) . then ( function ( files ) {
130
115
var searchPlatformTasks = files . map ( function ( file ) {
131
116
var extendedDir = path . join ( dir , file ) ;
@@ -141,7 +126,6 @@ function getProjectPlatformsRecursivelly (dir, configuredPlatforms, foundPlatfor
141
126
} ) ;
142
127
}
143
128
} else if ( configuredPlatforms [ file ] ) {
144
- // try to open telemetry file within folder (if exists - otherwise not interesting folder)
145
129
var telemetryFile = path . join ( extendedDir , constants . TELEMETRY_FILE_NAME ) ;
146
130
return Q . nfcall ( fs . readFile , telemetryFile , 'utf8' ) . then ( function ( data ) {
147
131
var generationInfo = JSON . parse ( data ) ;
@@ -164,7 +148,6 @@ function getProjectPlatformsRecursivelly (dir, configuredPlatforms, foundPlatfor
164
148
}
165
149
166
150
function getProjectPlatforms ( dir ) {
167
- // get available platform IDs
168
151
var configuredPlatforms = platformTools . getConfiguredPlatforms ( ) ;
169
152
170
153
return getProjectRoot ( dir || process . cwd ( ) ) . then ( function ( rootDir ) {
0 commit comments