@@ -4,11 +4,11 @@ const util = require('util')
4
4
const makeDir = require ( 'make-dir' )
5
5
const findUp = require ( 'find-up' )
6
6
const nextOnNetlify = require ( './src/index.js' )
7
- const AdmZip = require ( 'adm-zip' )
8
7
9
8
const validateNextUsage = require ( './helpers/validateNextUsage' )
10
9
const doesNotNeedPlugin = require ( './helpers/doesNotNeedPlugin' )
11
10
const getNextConfig = require ( './helpers/getNextConfig' )
11
+ const copyUnstableIncludedDirs = require ( './helpers/copyUnstableIncludedDirs' )
12
12
13
13
const pWriteFile = util . promisify ( fs . writeFile )
14
14
@@ -66,25 +66,7 @@ module.exports = {
66
66
}
67
67
68
68
const nextConfig = await getNextConfig ( utils . failBuild )
69
- const getNetlifyFunctionName = require ( './src/lib/helpers/getNetlifyFunctionName' )
70
-
71
- // any functions defined in the config need special handling
72
- for ( const name in nextConfig . unstableNetlifyFunctionsSupport || { } ) {
73
- const includeDirs = nextConfig . unstableNetlifyFunctionsSupport [ name ] . includeDirs || [ ]
74
- console . log ( 'Processing included dirs for ' , name )
75
-
76
- const zipName = path . join ( FUNCTIONS_DIST , getNetlifyFunctionName ( name ) + '.zip' )
77
- const zip = new AdmZip ( zipName )
78
- includeDirs . forEach ( ( includes ) => {
79
- if ( fs . lstatSync ( includes ) . isDirectory ( ) ) {
80
- // we add the files at the root of the ZIP because process.cwd()
81
- // points to `/` in serverless functions
82
- zip . addLocalFolder ( includes , includes )
83
- console . log ( `Added ${ includes } to ${ zipName } ` )
84
- }
85
- } )
86
- zip . writeZip ( zipName )
87
- }
69
+ copyUnstableIncludedDirs ( { nextConfig, functionsDist : FUNCTIONS_DIST } )
88
70
} ,
89
71
}
90
72
0 commit comments