Skip to content

Commit 0f439d4

Browse files
Merge branch 'AFD-1923-fix-spec-pattern-and-lls' into AFD-1921-use-default-port-cypress
2 parents 892efc5 + 649bf75 commit 0f439d4

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

bin/commands/runs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module.exports = function run(args, rawArgs) {
9999
// set the no-wrap
100100
utils.setNoWrap(bsConfig, args);
101101

102-
await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
102+
const { packagesInstalled } = await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
103103

104104
// set build tag caps
105105
utils.setBuildTags(bsConfig, args);
@@ -155,7 +155,7 @@ module.exports = function run(args, rawArgs) {
155155

156156
logger.debug("Started caching npm dependencies.");
157157
markBlockStart('zip.packageInstaller');
158-
return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
158+
return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}, packagesInstalled).then(function (packageData) {
159159
logger.debug("Completed caching npm dependencies.")
160160
markBlockEnd('zip.packageInstaller');
161161

bin/helpers/packageInstaller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,15 @@ const packageSetupAndInstaller = (bsConfig, packageDir, instrumentBlocks) => {
157157
})
158158
}
159159

160-
const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBlocks) => {
160+
const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBlocks, packagesInstalled) => {
161161
return new Promise(function (resolve) {
162162
let obj = {
163163
packageArchieveCreated: false
164164
};
165+
if (!packagesInstalled) {
166+
logger.debug("Skipping the caching of npm packages since package installed failed")
167+
return resolve(obj);
168+
}
165169
if (md5data.packageUrlPresent || !utils.isTrueString(bsConfig.run_settings.cache_dependencies)) {
166170
logger.debug("Skipping the caching of npm packages since BrowserStack has already cached your npm dependencies that have not changed since the last run.")
167171
return resolve(obj);

test/unit/bin/helpers/packageInstaller.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ describe("packageInstaller", () => {
505505
markBlockStart: sinon.stub(),
506506
markBlockEnd: sinon.stub()
507507
}
508-
return packageWrapperrewire(bsConfig, packageDir, packageFile, md5data, instrumentBlocks)
508+
return packageWrapperrewire(bsConfig, packageDir, packageFile, md5data, instrumentBlocks, true)
509509
.then((data) => {
510510
chai.assert.deepEqual(data, {packageArchieveCreated: true});
511511
})
@@ -530,13 +530,34 @@ describe("packageInstaller", () => {
530530
markBlockStart: sinon.stub(),
531531
markBlockEnd: sinon.stub()
532532
}
533-
return packageWrapperrewire(bsConfig, packageDir, packageFile, md5data, instrumentBlocks)
533+
return packageWrapperrewire(bsConfig, packageDir, packageFile, md5data, instrumentBlocks, true)
534534
.then((data) => {
535535
chai.assert.deepEqual(data, { packageArchieveCreated: false, error: 'test error stack' });
536536
})
537537
.catch((_error) => {
538538
chai.assert.fail("Promise error");
539539
});
540540
});
541+
542+
it("should reject with if issue in package install failed", () => {
543+
let packageWrapperrewire = packageInstaller.__get__('packageWrapper');
544+
let bsConfig = {
545+
run_settings: {
546+
cache_dependencies: true
547+
}
548+
};
549+
let md5data = {};
550+
let instrumentBlocks = {
551+
markBlockStart: sinon.stub(),
552+
markBlockEnd: sinon.stub()
553+
}
554+
return packageWrapperrewire(bsConfig, packageDir, packageFile, md5data, instrumentBlocks, false)
555+
.then((data) => {
556+
chai.assert.deepEqual(data, { packageArchieveCreated: false });
557+
})
558+
.catch((_error) => {
559+
chai.assert.fail("Promise error");
560+
});
561+
});
541562
});
542563
});

0 commit comments

Comments
 (0)