diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 392abeac..fb3b3155 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -72,9 +72,30 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => { }); } + // Split mac and win configs + let macPackageJSON = {}; + let winPackageJSON = {}; + Object.assign(macPackageJSON, packageJSON); + Object.assign(winPackageJSON, packageJSON); + + if (typeof runSettings.npm_dependencies === 'object') { + let macNpmDependencies = Object.assign({}, runSettings.npm_dependencies, runSettings.mac_npm_dependencies || {}); + let winNpmDependencies = Object.assign({}, runSettings.npm_dependencies, runSettings.win_npm_dependencies || {}); + + Object.assign(macPackageJSON, { + devDependencies: macNpmDependencies, + }); + + Object.assign(winPackageJSON, { + devDependencies: winNpmDependencies, + }); + } + if (Object.keys(packageJSON).length > 0) { - let packageJSONString = JSON.stringify(packageJSON, null, 4); - archive.append(packageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-package.json`}); + const macPackageJSONString = JSON.stringify(macPackageJSON, null, 4); + const winPackageJSONString = JSON.stringify(winPackageJSON, null, 4); + archive.append(macPackageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-mac-package.json`}); + archive.append(winPackageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-win-package.json`}); } //Create copy of package.json diff --git a/bin/helpers/checkUploaded.js b/bin/helpers/checkUploaded.js index 68588d45..2acb5cba 100644 --- a/bin/helpers/checkUploaded.js +++ b/bin/helpers/checkUploaded.js @@ -1,5 +1,6 @@ 'use strict'; const request = require('request'); +const { combineMacWinNpmDependencies } = require('./helper'); const crypto = require('crypto'), Constants = require('./constants'), @@ -59,7 +60,7 @@ const checkPackageMd5 = (runSettings) => { if (typeof runSettings.npm_dependencies === 'object') { Object.assign(packageJSON, { - devDependencies: utils.sortJsonKeys(runSettings.npm_dependencies), + devDependencies: utils.sortJsonKeys(combineMacWinNpmDependencies(runSettings)), }); } diff --git a/bin/helpers/constants.js b/bin/helpers/constants.js index a19f188d..c4b78d0f 100644 --- a/bin/helpers/constants.js +++ b/bin/helpers/constants.js @@ -343,7 +343,11 @@ const filesToIgnoreWhileUploading = [ "package.json", "**/package.json", "browserstack-package.json", + "browserstack-mac-package.json", + "browserstack-win-package.json", "**/browserstack-package.json", + "**/browserstack-mac-package.json", + "**/browserstack-win-package.json", "tests.zip", "**/tests.zip", "cypress.json", diff --git a/bin/helpers/helper.js b/bin/helpers/helper.js index 8a985829..3e89e971 100644 --- a/bin/helpers/helper.js +++ b/bin/helpers/helper.js @@ -441,3 +441,7 @@ exports.truncateString = (field, truncateSizeInBytes) => { return field; }; + +exports.combineMacWinNpmDependencies = (runSettings) => { + return Object.assign({}, runSettings.npm_dependencies, runSettings.win_npm_dependencies || {}, runSettings.mac_npm_dependencies || {}) +}; diff --git a/bin/helpers/packageInstaller.js b/bin/helpers/packageInstaller.js index a3f71fbe..18c4a30f 100644 --- a/bin/helpers/packageInstaller.js +++ b/bin/helpers/packageInstaller.js @@ -12,6 +12,8 @@ cliUtils = require("./utils"), util = require('util'); +const { combineMacWinNpmDependencies } = require("./helper"); + let nodeProcess; const setupPackageFolder = (runSettings, directoryPath) => { @@ -29,9 +31,10 @@ const setupPackageFolder = (runSettings, directoryPath) => { Object.assign(packageJSON, runSettings.package_config_options); } + // Combine win and mac specific dependencies if present if (typeof runSettings.npm_dependencies === 'object') { Object.assign(packageJSON, { - devDependencies: runSettings.npm_dependencies, + devDependencies: combineMacWinNpmDependencies(runSettings), }); } diff --git a/bin/helpers/utils.js b/bin/helpers/utils.js index d7639ee7..fc5fd614 100644 --- a/bin/helpers/utils.js +++ b/bin/helpers/utils.js @@ -222,6 +222,16 @@ exports.setDefaults = (bsConfig, args) => { bsConfig.run_settings.npm_dependencies = {} } + // setting win_npm_dependencies to {} if not present + if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.win_npm_dependencies)) { + bsConfig.run_settings.win_npm_dependencies = {} + } + + // setting mac_npm_dependencies to {} if not present + if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.mac_npm_dependencies)) { + bsConfig.run_settings.mac_npm_dependencies = {} + } + // setting connection_settings to {} if not present if (this.isUndefined(bsConfig.connection_settings)) { bsConfig.connection_settings = {};