@@ -4,12 +4,41 @@ var archiver = require('archiver');
44var request = require ( 'request' )
55var config = require ( './config' ) ;
66var logger = require ( "./logger" )
7+ var glob = require ( "glob" )
8+ const path = require ( 'path' ) ;
79
810
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 ) => {
1037 return new Promise ( function ( resolve , reject ) {
1138 var output = fs . createWriteStream ( filePath ) ;
1239
40+ var basePath = runSettings . base_path
41+
1342 var archive = archiver ( 'zip' , {
1443 zlib : { level : 9 } // Sets the compression level.
1544 } ) ;
@@ -36,9 +65,27 @@ const archiveSpecs = (specs, filePath) => {
3665
3766 archive . pipe ( output ) ;
3867
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 } ) ;
4289 } ) ;
4390
4491 archive . finalize ( ) ;
0 commit comments