Skip to content

Commit 8e341d9

Browse files
Merge pull request #92 from browserstack/optimize_zip_glob_pattern
Optimize Archive Upload
2 parents 92ced56 + b061c53 commit 8e341d9

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

bin/helpers/archiver.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => {
1616
logger.info(`Creating tests.zip with files in ${cypressFolderPath}`);
1717

1818
var archive = archiver('zip', {
19-
zlib: { level: 9 } // Sets the compression level.
19+
zlib: {level: 9}, // Sets the compression level.
2020
});
2121

2222
archive.on('warning', function (err) {
@@ -28,7 +28,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => {
2828
});
2929

3030
output.on('close', function () {
31-
resolve("Zipping completed");
31+
resolve('Zipping completed');
3232
});
3333

3434
output.on('end', function () {
@@ -43,9 +43,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => {
4343

4444
let ignoreFiles = getFilesToIgnore(runSettings, excludeFiles);
4545

46-
Constants.allowedFileTypes.forEach(fileType => {
47-
archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles, dot:true });
48-
});
46+
archive.glob(`**/*.+(${Constants.allowedFileTypes.join("|")})`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles, dot:true });
4947

5048
let packageJSON = {};
5149

@@ -54,19 +52,26 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => {
5452
}
5553

5654
if (typeof runSettings.npm_dependencies === 'object') {
57-
Object.assign(packageJSON, {devDependencies: runSettings.npm_dependencies});
55+
Object.assign(packageJSON, {
56+
devDependencies: runSettings.npm_dependencies,
57+
});
5858
}
5959

6060
if (Object.keys(packageJSON).length > 0) {
6161
let packageJSONString = JSON.stringify(packageJSON, null, 4);
62-
archive.append(packageJSONString, { name: 'browserstack-package.json' });
62+
archive.append(packageJSONString, {name: 'browserstack-package.json'});
6363
}
6464

6565
// do not add cypress.json if arg provided is false
66-
if (runSettings.cypress_config_file && runSettings.cypress_config_filename !== 'false') {
67-
let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath));
66+
if (
67+
runSettings.cypress_config_file &&
68+
runSettings.cypress_config_filename !== 'false'
69+
) {
70+
let cypressJSON = JSON.parse(
71+
fs.readFileSync(runSettings.cypressConfigFilePath)
72+
);
6873
let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
69-
archive.append(cypressJSONString, { name: 'cypress.json' });
74+
archive.append(cypressJSONString, {name: 'cypress.json'});
7075
}
7176

7277
archive.finalize();

0 commit comments

Comments
 (0)