@@ -12,12 +12,12 @@ import * as path from "path";
12
12
import { Yok } from "../../../yok" ;
13
13
import { ProjectFilesProviderBase } from "../../../services/project-files-provider-base" ;
14
14
15
- import * as temp from "temp" ;
15
+ import { mkdtempSync } from "fs" ;
16
+ import { tmpdir } from "os" ;
16
17
import { LiveSyncPaths } from "../../../constants" ;
17
18
import { TempServiceStub } from "../../../../../test/stubs" ;
18
19
import { IInjector } from "../../../definitions/yok" ;
19
20
import { IProjectFilesManager } from "../../../declarations" ;
20
- temp . track ( ) ;
21
21
22
22
const testedApplicationIdentifier = "com.telerik.myApp" ;
23
23
const iOSDeviceProjectRootPath = "/Documents/AppBuilder/LiveSync/app" ;
@@ -44,7 +44,7 @@ function createTestInjector(): IInjector {
44
44
testInjector . register ( "hostInfo" , HostInfo ) ;
45
45
testInjector . register (
46
46
"localToDevicePathDataFactory" ,
47
- LocalToDevicePathDataFactory
47
+ LocalToDevicePathDataFactory ,
48
48
) ;
49
49
testInjector . register ( "mobileHelper" , MobileHelper ) ;
50
50
testInjector . register ( "projectFilesProvider" , ProjectFilesProviderBase ) ;
@@ -61,12 +61,14 @@ function createTestInjector(): IInjector {
61
61
62
62
async function createFiles (
63
63
testInjector : IInjector ,
64
- filesToCreate : string [ ]
64
+ filesToCreate : string [ ] ,
65
65
) : Promise < string > {
66
- const directoryPath = temp . mkdirSync ( "Project Files Manager Tests" ) ;
66
+ const directoryPath = mkdtempSync (
67
+ path . join ( tmpdir ( ) , "Project Files Manager Tests-" ) ,
68
+ ) ;
67
69
68
70
_ . each ( filesToCreate , ( file ) =>
69
- createFile ( testInjector , file , "" , directoryPath )
71
+ createFile ( testInjector , file , "" , directoryPath ) ,
70
72
) ;
71
73
72
74
return directoryPath ;
@@ -76,11 +78,11 @@ function createFile(
76
78
testInjector : IInjector ,
77
79
fileToCreate : string ,
78
80
fileContent : string ,
79
- directoryPath ?: string
81
+ directoryPath ?: string ,
80
82
) : string {
81
83
const fs = testInjector . resolve ( "fs" ) ;
82
84
directoryPath = ! directoryPath
83
- ? temp . mkdirSync ( "Project Files Manager Tests" )
85
+ ? mkdtempSync ( path . join ( tmpdir ( ) , "Project Files Manager Tests-" ) )
84
86
: directoryPath ;
85
87
86
88
fs . writeFile ( path . join ( directoryPath , fileToCreate ) , fileContent ) ;
@@ -100,50 +102,52 @@ describe("Project Files Manager Tests", () => {
100
102
101
103
it ( "maps non-platform specific files to device file paths for ios platform" , async ( ) => {
102
104
const files = [ "~/TestApp/app/test.js" , "~/TestApp/app/myfile.js" ] ;
103
- const localToDevicePaths = await projectFilesManager . createLocalToDevicePaths (
104
- iOSDeviceAppData ,
105
- "~/TestApp/app" ,
106
- files ,
107
- [ ]
108
- ) ;
105
+ const localToDevicePaths =
106
+ await projectFilesManager . createLocalToDevicePaths (
107
+ iOSDeviceAppData ,
108
+ "~/TestApp/app" ,
109
+ files ,
110
+ [ ] ,
111
+ ) ;
109
112
110
113
_ . each ( localToDevicePaths , ( localToDevicePathData , index ) => {
111
114
assert . equal ( files [ index ] , localToDevicePathData . getLocalPath ( ) ) ;
112
115
assert . equal (
113
116
mobileHelper . buildDevicePath (
114
117
iOSDeviceProjectRootPath ,
115
- path . basename ( files [ index ] )
118
+ path . basename ( files [ index ] ) ,
116
119
) ,
117
- localToDevicePathData . getDevicePath ( )
120
+ localToDevicePathData . getDevicePath ( ) ,
118
121
) ;
119
122
assert . equal (
120
123
path . basename ( files [ index ] ) ,
121
- localToDevicePathData . getRelativeToProjectBasePath ( )
124
+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
122
125
) ;
123
126
} ) ;
124
127
} ) ;
125
128
126
129
it ( "maps non-platform specific files to device file paths for android platform" , async ( ) => {
127
130
const files = [ "~/TestApp/app/test.js" , "~/TestApp/app/myfile.js" ] ;
128
- const localToDevicePaths = await projectFilesManager . createLocalToDevicePaths (
129
- androidDeviceAppData ,
130
- "~/TestApp/app" ,
131
- files ,
132
- [ ]
133
- ) ;
131
+ const localToDevicePaths =
132
+ await projectFilesManager . createLocalToDevicePaths (
133
+ androidDeviceAppData ,
134
+ "~/TestApp/app" ,
135
+ files ,
136
+ [ ] ,
137
+ ) ;
134
138
135
139
_ . each ( localToDevicePaths , ( localToDevicePathData , index ) => {
136
140
assert . equal ( files [ index ] , localToDevicePathData . getLocalPath ( ) ) ;
137
141
assert . equal (
138
142
mobileHelper . buildDevicePath (
139
143
androidDeviceProjectRootPath ,
140
- path . basename ( files [ index ] )
144
+ path . basename ( files [ index ] ) ,
141
145
) ,
142
- localToDevicePathData . getDevicePath ( )
146
+ localToDevicePathData . getDevicePath ( ) ,
143
147
) ;
144
148
assert . equal (
145
149
path . basename ( files [ index ] ) ,
146
- localToDevicePathData . getRelativeToProjectBasePath ( )
150
+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
147
151
) ;
148
152
} ) ;
149
153
} ) ;
@@ -155,18 +159,18 @@ describe("Project Files Manager Tests", () => {
155
159
iOSDeviceAppData ,
156
160
"~/TestApp/app" ,
157
161
[ filePath ] ,
158
- [ ]
162
+ [ ] ,
159
163
)
160
164
) [ 0 ] ;
161
165
162
166
assert . equal ( filePath , localToDevicePathData . getLocalPath ( ) ) ;
163
167
assert . equal (
164
168
mobileHelper . buildDevicePath ( iOSDeviceProjectRootPath , "test.js" ) ,
165
- localToDevicePathData . getDevicePath ( )
169
+ localToDevicePathData . getDevicePath ( ) ,
166
170
) ;
167
171
assert . equal (
168
172
"test.ios.js" ,
169
- localToDevicePathData . getRelativeToProjectBasePath ( )
173
+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
170
174
) ;
171
175
} ) ;
172
176
@@ -177,18 +181,18 @@ describe("Project Files Manager Tests", () => {
177
181
androidDeviceAppData ,
178
182
"~/TestApp/app" ,
179
183
[ filePath ] ,
180
- [ ]
184
+ [ ] ,
181
185
)
182
186
) [ 0 ] ;
183
187
184
188
assert . equal ( filePath , localToDevicePathData . getLocalPath ( ) ) ;
185
189
assert . equal (
186
190
mobileHelper . buildDevicePath ( androidDeviceProjectRootPath , "test.js" ) ,
187
- localToDevicePathData . getDevicePath ( )
191
+ localToDevicePathData . getDevicePath ( ) ,
188
192
) ;
189
193
assert . equal (
190
194
"test.android.js" ,
191
- localToDevicePathData . getRelativeToProjectBasePath ( )
195
+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
192
196
) ;
193
197
} ) ;
194
198
@@ -199,7 +203,7 @@ describe("Project Files Manager Tests", () => {
199
203
projectFilesManager . processPlatformSpecificFiles (
200
204
directoryPath ,
201
205
"android" ,
202
- { }
206
+ { } ,
203
207
) ;
204
208
205
209
const fs = testInjector . resolve ( "fs" ) ;
@@ -228,7 +232,7 @@ describe("Project Files Manager Tests", () => {
228
232
testInjector ,
229
233
"test.release.x" ,
230
234
releaseFileContent ,
231
- directoryPath
235
+ directoryPath ,
232
236
) ;
233
237
234
238
projectFilesManager . processPlatformSpecificFiles ( directoryPath , "android" , {
@@ -241,7 +245,7 @@ describe("Project Files Manager Tests", () => {
241
245
assert . isFalse ( fs . exists ( path . join ( directoryPath , "test.release.x" ) ) ) ;
242
246
assert . isTrue (
243
247
fs . readFile ( path . join ( directoryPath , "test.x" ) ) . toString ( ) ===
244
- releaseFileContent
248
+ releaseFileContent ,
245
249
) ;
246
250
} ) ;
247
251
@@ -253,7 +257,7 @@ describe("Project Files Manager Tests", () => {
253
257
projectFilesManager . processPlatformSpecificFiles (
254
258
directoryPath ,
255
259
"android" ,
256
- { }
260
+ { } ,
257
261
) ;
258
262
259
263
const fs = testInjector . resolve ( "fs" ) ;
@@ -262,7 +266,7 @@ describe("Project Files Manager Tests", () => {
262
266
assert . isFalse ( fs . exists ( path . join ( directoryPath , "test.release.x" ) ) ) ;
263
267
assert . isTrue (
264
268
fs . readFile ( path . join ( directoryPath , "test.x" ) ) . toString ( ) ===
265
- debugFileContent
269
+ debugFileContent ,
266
270
) ;
267
271
} ) ;
268
272
0 commit comments