This repository was archived by the owner on May 22, 2024. It is now read-only.
File tree 4 files changed +30
-4
lines changed
fixtures/naming_conflict/func1
4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,6 @@ const createZipArchive = async function ({
108
108
const destPath = join ( destFolder , `${ basename ( filename , extension ) } .zip` )
109
109
const { archive, output } = startZip ( destPath )
110
110
111
- // We don't need an entry file if it would end up with the same path as the
112
- // function's main file.
113
- const needsEntryFile = ! isNamedLikeEntryFile ( mainFile , { basePath, filename } )
114
-
115
111
// There is a naming conflict with the entry file if one of the supporting
116
112
// files (i.e. not the main file) has the path that the entry file needs to
117
113
// take.
@@ -121,6 +117,10 @@ const createZipArchive = async function ({
121
117
mainFile,
122
118
} )
123
119
120
+ // We don't need an entry file if it would end up with the same path as the
121
+ // function's main file. Unless we have a file conflict and need to move everything into a subfolder
122
+ const needsEntryFile = hasEntryFileConflict || ! isNamedLikeEntryFile ( mainFile , { basePath, filename } )
123
+
124
124
// If there is a naming conflict, we move all user files (everything other
125
125
// than the entry file) to its own sub-directory.
126
126
const userNamespace = hasEntryFileConflict ? DEFAULT_USER_SUBDIRECTORY : ''
Original file line number Diff line number Diff line change
1
+ exports . handler = function handler ( event , context ) {
2
+ return import ( './func1.mjs' ) . then ( m => m . handler ( event , context ) )
3
+ }
Original file line number Diff line number Diff line change
1
+ export const handler = ( ) => true
Original file line number Diff line number Diff line change @@ -1383,6 +1383,28 @@ describe('zip-it-and-ship-it', () => {
1383
1383
} ,
1384
1384
)
1385
1385
1386
+ testMany (
1387
+ 'Generates a entry file if no entry file needed but naming conflict occurs' ,
1388
+ [ 'bundler_default' , 'bundler_nft' ] ,
1389
+ async ( options ) => {
1390
+ const fixtureName = 'naming_conflict'
1391
+ const opts = merge ( options , {
1392
+ basePath : join ( FIXTURES_DIR , fixtureName ) ,
1393
+ } )
1394
+ const { tmpDir } = await zipNode ( fixtureName , {
1395
+ opts,
1396
+ length : 1 ,
1397
+ } )
1398
+
1399
+ const function2Entry = await importFunctionFile ( `${ tmpDir } /func1.js` )
1400
+
1401
+ expect ( await function2Entry . handler ( ) ) . toBe ( true )
1402
+
1403
+ await expect ( `${ tmpDir } /src/func1.js` ) . toPathExist ( )
1404
+ await expect ( `${ tmpDir } /src/func1.mjs` ) . toPathExist ( )
1405
+ } ,
1406
+ )
1407
+
1386
1408
testMany (
1387
1409
'Bundles functions from multiple directories when the first argument of `zipFunctions()` is an array' ,
1388
1410
[ 'bundler_esbuild' , 'bundler_default' , 'bundler_nft' ] ,
You can’t perform that action at this time.
1 commit comments
github-actions[bot] commentedon Jan 12, 2023
⏱ Benchmark results