@@ -10,33 +10,27 @@ import * as fsAsync from "../../fsAsync";
10
10
* Locates the source code for a backend and creates an archive to eventually upload to GCS.
11
11
* Based heavily on functions upload logic in src/deploy/functions/prepareFunctionsUpload.ts.
12
12
*/
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 > {
17
14
const tmpFile = tmp . fileSync ( { prefix : `${ config . backendId } -` , postfix : ".zip" } ) . name ;
18
15
const fileStream = fs . createWriteStream ( tmpFile , {
19
16
flags : "w" ,
20
17
encoding : "binary" ,
21
18
} ) ;
22
19
const archive = archiver ( "zip" ) ;
23
20
24
- if ( ! projectRoot ) {
25
- projectRoot = process . cwd ( ) ;
26
- }
27
21
// We must ignore firebase-debug.log or weird things happen if you're in the public dir when you deploy.
28
22
const ignore = config . ignore || [ "node_modules" , ".git" ] ;
29
23
ignore . push ( "firebase-debug.log" , "firebase-debug.*.log" ) ;
30
- const gitIgnorePatterns = parseGitIgnorePatterns ( projectRoot ) ;
24
+ const gitIgnorePatterns = parseGitIgnorePatterns ( rootDir ) ;
31
25
ignore . push ( ...gitIgnorePatterns ) ;
32
26
try {
33
27
const files = await fsAsync . readdirRecursive ( {
34
- path : projectRoot ,
28
+ path : rootDir ,
35
29
ignore : ignore ,
36
30
isGitIgnore : true ,
37
31
} ) ;
38
32
for ( const file of files ) {
39
- const name = path . relative ( projectRoot , file . name ) ;
33
+ const name = path . relative ( rootDir , file . name ) ;
40
34
archive . file ( file . name , {
41
35
name,
42
36
mode : file . mode ,
@@ -49,7 +43,7 @@ export async function createArchive(
49
43
{ original : err as Error , exit : 1 } ,
50
44
) ;
51
45
}
52
- return { projectSourcePath : projectRoot , zippedSourcePath : tmpFile } ;
46
+ return tmpFile ;
53
47
}
54
48
55
49
function parseGitIgnorePatterns ( projectRoot : string , gitIgnorePath = ".gitignore" ) : string [ ] {
0 commit comments