Skip to content

Optimize Archive Upload #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions bin/helpers/archiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => {
logger.info(`Creating tests.zip with files in ${cypressFolderPath}`);

var archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
zlib: {level: 9}, // Sets the compression level.
});

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

output.on('close', function () {
resolve("Zipping completed");
resolve('Zipping completed');
});

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

let ignoreFiles = getFilesToIgnore(runSettings, excludeFiles);

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

let packageJSON = {};

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

if (typeof runSettings.npm_dependencies === 'object') {
Object.assign(packageJSON, {devDependencies: runSettings.npm_dependencies});
Object.assign(packageJSON, {
devDependencies: runSettings.npm_dependencies,
});
}

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

// do not add cypress.json if arg provided is false
if (runSettings.cypress_config_file && runSettings.cypress_config_filename !== 'false') {
let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath));
if (
runSettings.cypress_config_file &&
runSettings.cypress_config_filename !== 'false'
) {
let cypressJSON = JSON.parse(
fs.readFileSync(runSettings.cypressConfigFilePath)
);
let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
archive.append(cypressJSONString, { name: 'cypress.json' });
archive.append(cypressJSONString, {name: 'cypress.json'});
}

archive.finalize();
Expand Down