@@ -6,8 +6,6 @@ const ssri = require('ssri')
66const pacote = require ( 'pacote' )
77const pack = require ( '../index.js' )
88const tnock = require ( './fixtures/tnock.js' )
9- const { promisify } = require ( 'util' )
10- const rimraf = promisify ( require ( 'rimraf' ) )
119
1210const OPTS = {
1311 registry : 'https://mock.reg/'
@@ -23,7 +21,7 @@ t.test('packs from local directory', async t => {
2321 } , null , 2 ) ,
2422 'index.js' : 'hello'
2523 } )
26- const target = `${ __dirname } /my-cool-pkg-1.0.0.tgz`
24+ const target = `${ testDir } /my-cool-pkg-1.0.0.tgz`
2725
2826 const cwd = process . cwd ( )
2927 process . chdir ( testDir )
@@ -57,14 +55,12 @@ t.test('packs from local directory', async t => {
5755 t . deepEqual ( tarContents , contents ,
5856 'packed directory matches expectations'
5957 )
60-
61- await rimraf ( target )
6258} )
6359
6460t . test ( 'packs from local directory on target' , async t => {
6561 const testDir = t . testdir ( {
6662 'package.json' : JSON . stringify ( {
67- name : 'my-cool -pkg' ,
63+ name : 'my-local -pkg' ,
6864 version : '1.0.0' ,
6965 bundledDependencies : [ 'a' ]
7066 } , null , 2 ) ,
@@ -79,26 +75,26 @@ t.test('packs from local directory on target', async t => {
7975 }
8076 } )
8177
82- const target = `${ __dirname } /my-cool -pkg-1.0.0.tgz`
78+ const target = `${ testDir } /my-local -pkg-1.0.0.tgz`
8379
8480 const tarContents = await pack ( testDir , { target } )
8581 const integrity = await ssri . fromStream ( fs . createReadStream ( target ) , {
8682 algorithms : [ 'sha512' ]
8783 } )
8884
8985 const contents = {
90- 91- name : 'my-cool -pkg' ,
86+ 87+ name : 'my-local -pkg' ,
9288 version : '1.0.0' ,
93- size : 260 ,
94- unpackedSize : 133 ,
95- shasum : '535bdcc05fd4a1b7f2603c5527a7c63ba5b88cff ' ,
89+ size : 261 ,
90+ unpackedSize : 134 ,
91+ shasum : 'dbbd93ed67b3c2941dc8096c5ec66b10f5606690 ' ,
9692 integrity : ssri . parse ( integrity . sha512 [ 0 ] ) ,
97- filename : 'my-cool -pkg-1.0.0.tgz' ,
93+ filename : 'my-local -pkg-1.0.0.tgz' ,
9894 files : [
9995 { path : 'index.js' , size : 5 , mode : 420 } ,
10096 { path : 'node_modules/a/package.json' , size : 39 , mode : 420 } ,
101- { path : 'package.json' , size : 89 , mode : 420 }
97+ { path : 'package.json' , size : 90 , mode : 420 }
10298 ] ,
10399 entryCount : 3 ,
104100 bundled : [ 'a' ]
@@ -107,37 +103,33 @@ t.test('packs from local directory on target', async t => {
107103 t . deepEqual ( tarContents , contents ,
108104 'packed directory matches expectations'
109105 )
110-
111- await rimraf ( target )
112106} )
113107
114108t . test ( 'packs from registry spec' , async t => {
115109 const testDir = t . testdir ( {
116110 'package.json' : JSON . stringify ( {
117- name : 'my-cool- pkg' ,
111+ name : 'my-pkg' ,
118112 version : '1.0.0'
119113 } , null , 2 ) ,
120114 'index.js' : 'hello'
121115 } )
122- // weird windows thing. when we write the file into the testdir
123- // on this test, it breaks all kinds of stuff when it tries to
124- // clean it up.
125- const target = `${ __dirname } /my-cool-pkg-1.0.0.tgz`
126- const spec = 'my-cool-pkg'
116+
117+ const spec = 'my-pkg'
118+ const target = `${ testDir } /my-pkg-1.0.0.tgz`
127119
128120 const tarData = await pacote . tarball ( `file:${ testDir } ` )
129121 const integrity = ssri . fromData ( tarData , { algorithms : [ 'sha512' ] } )
130122 const packument = {
131- _id : 'my-cool- pkg' ,
132- name : 'my-cool- pkg' ,
123+ _id : 'my-pkg' ,
124+ name : 'my-pkg' ,
133125 description : 'some stuff' ,
134126 'dist-tags' : {
135127 latest : '1.0.0'
136128 } ,
137129 versions : {
138130 '1.0.0' : {
139131 _nodeVersion : process . versions . node ,
140- name : 'my-cool- pkg' ,
132+ name : 'my-pkg' ,
141133 version : '1.0.0' ,
142134 description : 'some stuff' ,
143135 dist : {
@@ -159,21 +151,21 @@ t.test('packs from registry spec', async t => {
159151 }
160152
161153 const srv = tnock ( t , REG )
162- srv . get ( '/my-cool- pkg' ) . reply ( 200 , packument )
154+ srv . get ( '/my-pkg' ) . reply ( 200 , packument )
163155
164156 const tarContents = await pack ( spec , { ...OPTS , target } )
165157 const contents = {
166- 167- name : 'my-cool- pkg' ,
158+ 159+ name : 'my-pkg' ,
168160 version : '1.0.0' ,
169- size : 187 ,
170- unpackedSize : 54 ,
171- shasum : 'e4db5fa79b694e5f94cb7a48250eb5a728f9669f ' ,
161+ size : 183 ,
162+ unpackedSize : 49 ,
163+ shasum : 'fb8fce241a824279f95f16648dade6f760b85087 ' ,
172164 integrity,
173- filename : 'my-cool- pkg-1.0.0.tgz' ,
165+ filename : 'my-pkg-1.0.0.tgz' ,
174166 files : [
175167 { path : 'index.js' , size : 5 , mode : 420 } ,
176- { path : 'package.json' , size : 49 , mode : 420 }
168+ { path : 'package.json' , size : 44 , mode : 420 }
177169 ] ,
178170 entryCount : 2 ,
179171 bundled : [ ]
@@ -182,6 +174,4 @@ t.test('packs from registry spec', async t => {
182174 t . deepEqual ( tarContents , contents ,
183175 'packed directory matches expectations'
184176 )
185-
186- await rimraf ( target )
187177} )
0 commit comments