@@ -12,6 +12,7 @@ const test = require('tap').test
12
12
13
13
const Dir = Tacks . Dir
14
14
const File = Tacks . File
15
+ const cacheDir = common . cache
15
16
const testDir = common . pkg
16
17
17
18
const EXEC_OPTS = { cwd : testDir }
@@ -47,7 +48,7 @@ test('setup', () => {
47
48
const fixture = new Tacks ( Dir ( {
48
49
'package.json' : File ( PKG )
49
50
} ) )
50
- return rimraf ( testDir ) . then ( ( ) => {
51
+ return Promise . all ( [ rimraf ( cacheDir ) , rimraf ( testDir ) ] ) . then ( ( ) => {
51
52
fixture . create ( testDir )
52
53
return mr ( { port : common . port } )
53
54
} )
@@ -306,7 +307,35 @@ test('errors if package-lock.json invalid', (t) => {
306
307
)
307
308
} )
308
309
310
+ test ( 'correct cache location when using cache config' , ( t ) => {
311
+ const fixture = new Tacks ( Dir ( {
312
+ 'package.json' : File ( PKG ) ,
313
+ 'package-lock.json' : File ( RAW_LOCKFILE )
314
+ } ) )
315
+ return Promise . all ( [ rimraf ( cacheDir ) , rimraf ( testDir ) ] )
316
+ . then ( ( ) => fixture . create ( cacheDir ) )
317
+ . then ( ( ) => fixture . create ( testDir ) )
318
+ . then ( ( ) => common . npm ( [
319
+ 'ci' ,
320
+ `--cache=${ cacheDir } ` ,
321
+ '--foo=asdf' ,
322
+ '--registry' , common . registry ,
323
+ '--loglevel' , 'warn'
324
+ ] , EXEC_OPTS ) )
325
+ . then ( ( ret ) => {
326
+ const code = ret [ 0 ]
327
+ const stderr = ret [ 2 ]
328
+ t . equal ( code , 0 , 'command completed without error' )
329
+ t . equal ( stderr . trim ( ) , '' , 'no output on stderr' )
330
+ return fs . readdirAsync ( path . join ( cacheDir , '_cacache' ) )
331
+ } )
332
+ . then ( ( modules ) => {
333
+ t . ok ( modules , 'should create _cacache folder' )
334
+ t . end ( )
335
+ } )
336
+ } )
337
+
309
338
test ( 'cleanup' , ( ) => {
310
339
SERVER . close ( )
311
- return rimraf ( testDir )
340
+ return Promise . all ( [ rimraf ( cacheDir ) , rimraf ( testDir ) ] )
312
341
} )
0 commit comments