Skip to content

Commit 9463861

Browse files
committed
npm install cache and messaging
1 parent e05069c commit 9463861

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

bin/helpers/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const userMessages = {
3838
NO_NPM_DEPENDENCIES_READ_MORE: "Read more about npm dependencies here: https://www.browserstack.com/docs/automate/cypress/npm-packages. You can suppress this warning by using --disable-npm-warning flag.",
3939
VALIDATING_CONFIG: "Validating the config",
4040
UPLOADING_TESTS: "Uploading the tests to BrowserStack",
41-
UPLOADING_NPM_PACKAGES: "Uploading npm packages to BrowserStack",
41+
UPLOADING_NPM_PACKAGES: "Uploading required node_modules to BrowserStack",
4242
LOCAL_TRUE: "you will now be able to test localhost / private URLs",
4343
LOCAL_FALSE: "you won't be able to test localhost / private URLs",
4444
EXIT_SYNC_CLI_MESSAGE: "Exiting the CLI, but your build is still running. You can use the --sync option to keep getting test updates. You can also use the build-info <build-id> command now.",

bin/helpers/fileHelpers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ exports.deleteZip = () => {
3636
}
3737
};
3838

39-
exports.deletePackageArchieve = () => {
39+
exports.deletePackageArchieve = (logging = true) => {
4040
try {
4141
delete process.env.CYPRESS_INSTALL_BINARY;
4242
fs.removeSync(config.packageFileName);
4343
fs.removeSync(config.packageDirName);
44-
logger.info(Constants.userMessages.NPM_DELETED);
44+
if (logging) logger.info(Constants.userMessages.NPM_DELETED);
4545
return 0;
4646
} catch (err) {
47-
logger.info(Constants.userMessages.NPM_DELETE_FAILED);
47+
if (logging) logger.info(Constants.userMessages.NPM_DELETE_FAILED);
4848
return 1;
4949
}
5050
};

bin/helpers/packageInstaller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
const npm = require('npm'),
33
archiver = require("archiver"),
44
path = require('path'),
5+
os = require('os'),
56
fs = require('fs-extra'),
67
fileHelpers = require('./fileHelpers'),
8+
logger = require("./logger").winstonLogger,
79
Constants = require('./constants'),
810
process = require('process'),
911
utils = require('./utils');
1012

1113
const setupPackageFolder = (runSettings, directoryPath) => {
1214
return new Promise(function (resolve, reject) {
13-
fileHelpers.deletePackageArchieve();
15+
fileHelpers.deletePackageArchieve(false);
1416
fs.mkdir(directoryPath, function (err) {
1517
try {
1618
if (err) {
@@ -51,6 +53,7 @@ const packageInstall = (packageDir) => {
5153
return new Promise(function (resolve, reject) {
5254
let savedPrefix = null;
5355
let npmLoad = Constants.packageInstallerOptions.npmLoad
56+
npmLoad["cache"] = fs.mkdtempSync(`${os.tmpdir()}${path.sep}`);
5457
const installCallback = (err, result) => {
5558
npm.prefix = savedPrefix;
5659
if (err) {
@@ -110,6 +113,7 @@ const packageWrappper = (bsConfig, packageDir, packageFile, md5data, instrumentB
110113
if (md5data.packageUrlPresent || !utils.isTrueString(bsConfig.run_settings.cache_dependencies)) {
111114
return resolve(obj);
112115
}
116+
logger.info(`Installing required dependencies and building the package to upload to BrowserStack`);
113117
instrumentBlocks.markBlockStart("packageInstaller.folderSetup");
114118
return setupPackageFolder(bsConfig.run_settings, packageDir).then((_result) => {
115119
process.env.CYPRESS_INSTALL_BINARY = 0

0 commit comments

Comments
 (0)