@@ -4,12 +4,41 @@ var archiver = require('archiver');
4
4
var request = require ( 'request' )
5
5
var config = require ( './config' ) ;
6
6
var logger = require ( "./logger" )
7
+ var glob = require ( "glob" )
8
+ const path = require ( 'path' ) ;
7
9
8
10
9
- const archiveSpecs = ( specs , filePath ) => {
11
+ const getFiles = ( jsGlobs , basePath , cb ) => {
12
+ files = [ ] ;
13
+
14
+ jsGlobs . forEach ( function ( item ) {
15
+ logger . log ( "Adding " + item + " to zip" ) ;
16
+ files = glob . sync ( basePath + item )
17
+ // files.forEach(file => {
18
+ // fileNames.push(path.relative(basePath, file))
19
+ // });
20
+ // shortFiles = files.map(file => path.relative(basePath, file))
21
+ // archive.append(JSON.stringify({"support": shortFiles}), {name: "cypress_helpers.json"})
22
+ } ) ;
23
+
24
+ files = files . map ( file => path . relative ( basePath , file ) )
25
+
26
+ console . log ( files ) ;
27
+ if ( cb ) {
28
+ console . log ( 'calling callback' ) ;
29
+ cb ( files ) ;
30
+ }
31
+
32
+
33
+ return files ;
34
+ }
35
+
36
+ const archiveSpecs = ( runSettings , filePath ) => {
10
37
return new Promise ( function ( resolve , reject ) {
11
38
var output = fs . createWriteStream ( filePath ) ;
12
39
40
+ var basePath = runSettings . base_path
41
+
13
42
var archive = archiver ( 'zip' , {
14
43
zlib : { level : 9 } // Sets the compression level.
15
44
} ) ;
@@ -36,9 +65,27 @@ const archiveSpecs = (specs, filePath) => {
36
65
37
66
archive . pipe ( output ) ;
38
67
39
- specs . forEach ( function ( item , index ) {
40
- logger . log ( "Adding " + item + " to zip" ) ;
41
- archive . glob ( item ) ;
68
+ fileNames = [ ] ;
69
+
70
+ getFiles ( runSettings . specs , basePath , ( files ) => {
71
+ fileNames = fileNames . concat ( files ) ;
72
+ } )
73
+
74
+ getFiles ( runSettings . supports , basePath , ( files ) => {
75
+ archive . append ( JSON . stringify ( { "support" : files } ) , { name : "cypress_helpers.json" } )
76
+ fileNames = fileNames . concat ( files ) ;
77
+ } )
78
+
79
+ getFiles ( runSettings . plugins , basePath , ( files ) => {
80
+ fileNames = fileNames . concat ( files ) ;
81
+ } )
82
+
83
+ getFiles ( runSettings . fixtures , basePath , ( files ) => {
84
+ fileNames = fileNames . concat ( files ) ;
85
+ } )
86
+
87
+ fileNames . forEach ( function ( file ) {
88
+ archive . file ( basePath + file , { name : file } ) ;
42
89
} ) ;
43
90
44
91
archive . finalize ( ) ;
0 commit comments