@@ -12,12 +12,12 @@ import * as path from "path";
1212import { Yok } from "../../../yok" ;
1313import { ProjectFilesProviderBase } from "../../../services/project-files-provider-base" ;
1414
15- import * as temp from "temp" ;
15+ import { mkdtempSync } from "fs" ;
16+ import { tmpdir } from "os" ;
1617import { LiveSyncPaths } from "../../../constants" ;
1718import { TempServiceStub } from "../../../../../test/stubs" ;
1819import { IInjector } from "../../../definitions/yok" ;
1920import { IProjectFilesManager } from "../../../declarations" ;
20- temp . track ( ) ;
2121
2222const testedApplicationIdentifier = "com.telerik.myApp" ;
2323const iOSDeviceProjectRootPath = "/Documents/AppBuilder/LiveSync/app" ;
@@ -44,7 +44,7 @@ function createTestInjector(): IInjector {
4444 testInjector . register ( "hostInfo" , HostInfo ) ;
4545 testInjector . register (
4646 "localToDevicePathDataFactory" ,
47- LocalToDevicePathDataFactory
47+ LocalToDevicePathDataFactory ,
4848 ) ;
4949 testInjector . register ( "mobileHelper" , MobileHelper ) ;
5050 testInjector . register ( "projectFilesProvider" , ProjectFilesProviderBase ) ;
@@ -61,12 +61,14 @@ function createTestInjector(): IInjector {
6161
6262async function createFiles (
6363 testInjector : IInjector ,
64- filesToCreate : string [ ]
64+ filesToCreate : string [ ] ,
6565) : Promise < string > {
66- const directoryPath = temp . mkdirSync ( "Project Files Manager Tests" ) ;
66+ const directoryPath = mkdtempSync (
67+ path . join ( tmpdir ( ) , "Project Files Manager Tests-" ) ,
68+ ) ;
6769
6870 _ . each ( filesToCreate , ( file ) =>
69- createFile ( testInjector , file , "" , directoryPath )
71+ createFile ( testInjector , file , "" , directoryPath ) ,
7072 ) ;
7173
7274 return directoryPath ;
@@ -76,11 +78,11 @@ function createFile(
7678 testInjector : IInjector ,
7779 fileToCreate : string ,
7880 fileContent : string ,
79- directoryPath ?: string
81+ directoryPath ?: string ,
8082) : string {
8183 const fs = testInjector . resolve ( "fs" ) ;
8284 directoryPath = ! directoryPath
83- ? temp . mkdirSync ( "Project Files Manager Tests" )
85+ ? mkdtempSync ( path . join ( tmpdir ( ) , "Project Files Manager Tests-" ) )
8486 : directoryPath ;
8587
8688 fs . writeFile ( path . join ( directoryPath , fileToCreate ) , fileContent ) ;
@@ -100,50 +102,52 @@ describe("Project Files Manager Tests", () => {
100102
101103 it ( "maps non-platform specific files to device file paths for ios platform" , async ( ) => {
102104 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+ ) ;
109112
110113 _ . each ( localToDevicePaths , ( localToDevicePathData , index ) => {
111114 assert . equal ( files [ index ] , localToDevicePathData . getLocalPath ( ) ) ;
112115 assert . equal (
113116 mobileHelper . buildDevicePath (
114117 iOSDeviceProjectRootPath ,
115- path . basename ( files [ index ] )
118+ path . basename ( files [ index ] ) ,
116119 ) ,
117- localToDevicePathData . getDevicePath ( )
120+ localToDevicePathData . getDevicePath ( ) ,
118121 ) ;
119122 assert . equal (
120123 path . basename ( files [ index ] ) ,
121- localToDevicePathData . getRelativeToProjectBasePath ( )
124+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
122125 ) ;
123126 } ) ;
124127 } ) ;
125128
126129 it ( "maps non-platform specific files to device file paths for android platform" , async ( ) => {
127130 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+ ) ;
134138
135139 _ . each ( localToDevicePaths , ( localToDevicePathData , index ) => {
136140 assert . equal ( files [ index ] , localToDevicePathData . getLocalPath ( ) ) ;
137141 assert . equal (
138142 mobileHelper . buildDevicePath (
139143 androidDeviceProjectRootPath ,
140- path . basename ( files [ index ] )
144+ path . basename ( files [ index ] ) ,
141145 ) ,
142- localToDevicePathData . getDevicePath ( )
146+ localToDevicePathData . getDevicePath ( ) ,
143147 ) ;
144148 assert . equal (
145149 path . basename ( files [ index ] ) ,
146- localToDevicePathData . getRelativeToProjectBasePath ( )
150+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
147151 ) ;
148152 } ) ;
149153 } ) ;
@@ -155,18 +159,18 @@ describe("Project Files Manager Tests", () => {
155159 iOSDeviceAppData ,
156160 "~/TestApp/app" ,
157161 [ filePath ] ,
158- [ ]
162+ [ ] ,
159163 )
160164 ) [ 0 ] ;
161165
162166 assert . equal ( filePath , localToDevicePathData . getLocalPath ( ) ) ;
163167 assert . equal (
164168 mobileHelper . buildDevicePath ( iOSDeviceProjectRootPath , "test.js" ) ,
165- localToDevicePathData . getDevicePath ( )
169+ localToDevicePathData . getDevicePath ( ) ,
166170 ) ;
167171 assert . equal (
168172 "test.ios.js" ,
169- localToDevicePathData . getRelativeToProjectBasePath ( )
173+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
170174 ) ;
171175 } ) ;
172176
@@ -177,18 +181,18 @@ describe("Project Files Manager Tests", () => {
177181 androidDeviceAppData ,
178182 "~/TestApp/app" ,
179183 [ filePath ] ,
180- [ ]
184+ [ ] ,
181185 )
182186 ) [ 0 ] ;
183187
184188 assert . equal ( filePath , localToDevicePathData . getLocalPath ( ) ) ;
185189 assert . equal (
186190 mobileHelper . buildDevicePath ( androidDeviceProjectRootPath , "test.js" ) ,
187- localToDevicePathData . getDevicePath ( )
191+ localToDevicePathData . getDevicePath ( ) ,
188192 ) ;
189193 assert . equal (
190194 "test.android.js" ,
191- localToDevicePathData . getRelativeToProjectBasePath ( )
195+ localToDevicePathData . getRelativeToProjectBasePath ( ) ,
192196 ) ;
193197 } ) ;
194198
@@ -199,7 +203,7 @@ describe("Project Files Manager Tests", () => {
199203 projectFilesManager . processPlatformSpecificFiles (
200204 directoryPath ,
201205 "android" ,
202- { }
206+ { } ,
203207 ) ;
204208
205209 const fs = testInjector . resolve ( "fs" ) ;
@@ -228,7 +232,7 @@ describe("Project Files Manager Tests", () => {
228232 testInjector ,
229233 "test.release.x" ,
230234 releaseFileContent ,
231- directoryPath
235+ directoryPath ,
232236 ) ;
233237
234238 projectFilesManager . processPlatformSpecificFiles ( directoryPath , "android" , {
@@ -241,7 +245,7 @@ describe("Project Files Manager Tests", () => {
241245 assert . isFalse ( fs . exists ( path . join ( directoryPath , "test.release.x" ) ) ) ;
242246 assert . isTrue (
243247 fs . readFile ( path . join ( directoryPath , "test.x" ) ) . toString ( ) ===
244- releaseFileContent
248+ releaseFileContent ,
245249 ) ;
246250 } ) ;
247251
@@ -253,7 +257,7 @@ describe("Project Files Manager Tests", () => {
253257 projectFilesManager . processPlatformSpecificFiles (
254258 directoryPath ,
255259 "android" ,
256- { }
260+ { } ,
257261 ) ;
258262
259263 const fs = testInjector . resolve ( "fs" ) ;
@@ -262,7 +266,7 @@ describe("Project Files Manager Tests", () => {
262266 assert . isFalse ( fs . exists ( path . join ( directoryPath , "test.release.x" ) ) ) ;
263267 assert . isTrue (
264268 fs . readFile ( path . join ( directoryPath , "test.x" ) ) . toString ( ) ===
265- debugFileContent
269+ debugFileContent ,
266270 ) ;
267271 } ) ;
268272
0 commit comments