@@ -181,46 +181,47 @@ describe("fs.ts", () => {
181181 const packagePath = ( path : string ) =>
182182 normalizePath ( join ( fixture . cwd , path ) ) ;
183183
184+ const inferExports = ( ) =>
185+ inferPackageEntryPointPaths ( fixture . cwd + "/package.json" ) . map (
186+ ( s ) => [ s [ 0 ] , normalizePath ( s [ 1 ] ) ] ,
187+ ) ;
188+
184189 it ( "Supports string exports shorthand" , ( ) => {
185- const pkg = fixture . addJsonFile ( "package.json" , {
190+ fixture . addJsonFile ( "package.json" , {
186191 main : "./main.js" ,
187192 exports : "./exp.js" ,
188193 } ) ;
189194 fixture . write ( ) ;
190195
191- equal ( inferPackageEntryPointPaths ( pkg . path ) , [
192- [ "." , packagePath ( "exp.js" ) ] ,
193- ] ) ;
196+ equal ( inferExports ( ) , [ [ "." , packagePath ( "exp.js" ) ] ] ) ;
194197 } ) ;
195198
196199 it ( "Uses the main field if exports are not defined" , ( ) => {
197- const pkg = fixture . addJsonFile ( "package.json" , {
200+ fixture . addJsonFile ( "package.json" , {
198201 main : "./main.js" ,
199202 } ) ;
200203 fixture . write ( ) ;
201204
202- equal ( inferPackageEntryPointPaths ( pkg . path ) , [
203- [ "." , packagePath ( "main.js" ) ] ,
204- ] ) ;
205+ equal ( inferExports ( ) , [ [ "." , packagePath ( "main.js" ) ] ] ) ;
205206 } ) ;
206207
207208 it ( "Supports simple object exports" , ( ) => {
208- const pkg = fixture . addJsonFile ( "package.json" , {
209+ fixture . addJsonFile ( "package.json" , {
209210 exports : {
210211 "." : "main.js" ,
211212 foo : "foo.js" ,
212213 } ,
213214 } ) ;
214215 fixture . write ( ) ;
215216
216- equal ( inferPackageEntryPointPaths ( pkg . path ) , [
217+ equal ( inferExports ( ) , [
217218 [ "." , packagePath ( "main.js" ) ] ,
218219 [ "foo" , packagePath ( "foo.js" ) ] ,
219220 ] ) ;
220221 } ) ;
221222
222223 it ( "Uses export conditions" , ( ) => {
223- const pkg = fixture . addJsonFile ( "package.json" , {
224+ fixture . addJsonFile ( "package.json" , {
224225 exports : {
225226 "." : "main.js" ,
226227 a : {
@@ -243,7 +244,7 @@ describe("fs.ts", () => {
243244 } ) ;
244245 fixture . write ( ) ;
245246
246- equal ( inferPackageEntryPointPaths ( pkg . path ) , [
247+ equal ( inferExports ( ) , [
247248 [ "." , packagePath ( "main.js" ) ] ,
248249 [ "a" , packagePath ( "a.ts" ) ] ,
249250 [ "b" , packagePath ( "b.ts" ) ] ,
@@ -253,7 +254,7 @@ describe("fs.ts", () => {
253254 } ) ;
254255
255256 it ( "Handles arrays of export conditions" , ( ) => {
256- const pkg = fixture . addJsonFile ( "package.json" , {
257+ fixture . addJsonFile ( "package.json" , {
257258 exports : {
258259 "." : [ "main.js" ] ,
259260 a : [ "does-not-exist.js" , "exists.js" ] ,
@@ -263,14 +264,14 @@ describe("fs.ts", () => {
263264 fixture . addFile ( "exists.js" ) ;
264265 fixture . write ( ) ;
265266
266- equal ( inferPackageEntryPointPaths ( pkg . path ) , [
267+ equal ( inferExports ( ) , [
267268 [ "." , packagePath ( "main.js" ) ] ,
268269 [ "a" , packagePath ( "exists.js" ) ] ,
269270 ] ) ;
270271 } ) ;
271272
272273 it ( "Handles nested export conditions" , ( ) => {
273- const pkg = fixture . addJsonFile ( "package.json" , {
274+ fixture . addJsonFile ( "package.json" , {
274275 exports : {
275276 a : {
276277 notMatched : {
@@ -285,13 +286,11 @@ describe("fs.ts", () => {
285286 } ) ;
286287 fixture . write ( ) ;
287288
288- equal ( inferPackageEntryPointPaths ( pkg . path ) , [
289- [ "a" , packagePath ( "a.ts" ) ] ,
290- ] ) ;
289+ equal ( inferExports ( ) , [ [ "a" , packagePath ( "a.ts" ) ] ] ) ;
291290 } ) ;
292291
293292 it ( "Handles a single wildcard" , ( ) => {
294- const pkg = fixture . addJsonFile ( "package.json" , {
293+ fixture . addJsonFile ( "package.json" , {
295294 exports : {
296295 "a/*.js" : "src/*.js" ,
297296 "b/*.js" : "src/*/*.ts" ,
@@ -304,7 +303,7 @@ describe("fs.ts", () => {
304303 fixture . addFile ( "src/6/6.ts" ) ;
305304 fixture . write ( ) ;
306305
307- equal ( inferPackageEntryPointPaths ( pkg . path ) , [
306+ equal ( inferExports ( ) , [
308307 [ "a/1.js" , packagePath ( "src/1.js" ) ] ,
309308 [ "a/2.js" , packagePath ( "src/2.js" ) ] ,
310309 [ "a/3/4.js" , packagePath ( "src/3/4.js" ) ] ,
0 commit comments