@@ -10,33 +10,27 @@ import * as fsAsync from "../../fsAsync";
1010 * Locates the source code for a backend and creates an archive to eventually upload to GCS.
1111 * Based heavily on functions upload logic in src/deploy/functions/prepareFunctionsUpload.ts.
1212 */
13- export async function createArchive (
14- config : AppHostingSingle ,
15- projectRoot ?: string ,
16- ) : Promise < { projectSourcePath : string ; zippedSourcePath : string } > {
13+ export async function createArchive ( config : AppHostingSingle , rootDir : string ) : Promise < string > {
1714 const tmpFile = tmp . fileSync ( { prefix : `${ config . backendId } -` , postfix : ".zip" } ) . name ;
1815 const fileStream = fs . createWriteStream ( tmpFile , {
1916 flags : "w" ,
2017 encoding : "binary" ,
2118 } ) ;
2219 const archive = archiver ( "zip" ) ;
2320
24- if ( ! projectRoot ) {
25- projectRoot = process . cwd ( ) ;
26- }
2721 // We must ignore firebase-debug.log or weird things happen if you're in the public dir when you deploy.
2822 const ignore = config . ignore || [ "node_modules" , ".git" ] ;
2923 ignore . push ( "firebase-debug.log" , "firebase-debug.*.log" ) ;
30- const gitIgnorePatterns = parseGitIgnorePatterns ( projectRoot ) ;
24+ const gitIgnorePatterns = parseGitIgnorePatterns ( rootDir ) ;
3125 ignore . push ( ...gitIgnorePatterns ) ;
3226 try {
3327 const files = await fsAsync . readdirRecursive ( {
34- path : projectRoot ,
28+ path : rootDir ,
3529 ignore : ignore ,
3630 isGitIgnore : true ,
3731 } ) ;
3832 for ( const file of files ) {
39- const name = path . relative ( projectRoot , file . name ) ;
33+ const name = path . relative ( rootDir , file . name ) ;
4034 archive . file ( file . name , {
4135 name,
4236 mode : file . mode ,
@@ -49,7 +43,7 @@ export async function createArchive(
4943 { original : err as Error , exit : 1 } ,
5044 ) ;
5145 }
52- return { projectSourcePath : projectRoot , zippedSourcePath : tmpFile } ;
46+ return tmpFile ;
5347}
5448
5549function parseGitIgnorePatterns ( projectRoot : string , gitIgnorePath = ".gitignore" ) : string [ ] {
0 commit comments