diff --git a/aio/tools/ng-packages-installer/index.js b/aio/tools/ng-packages-installer/index.js index 23af920e66..3dd30a516c 100644 --- a/aio/tools/ng-packages-installer/index.js +++ b/aio/tools/ng-packages-installer/index.js @@ -62,7 +62,7 @@ class NgPackagesInstaller { * contents and acts as an indicator that dependencies have been overridden. */ installLocalDependencies() { - if (this._checkLocalMarker() !== true || this.force) { + if (this.force || !this._checkLocalMarker()) { const pathToPackageConfig = path.resolve(this.projectDir, PACKAGE_JSON); const packages = this._getDistPackages(); diff --git a/aio/tools/ng-packages-installer/index.spec.js b/aio/tools/ng-packages-installer/index.spec.js index e8950045ab..b532a05e20 100644 --- a/aio/tools/ng-packages-installer/index.spec.js +++ b/aio/tools/ng-packages-installer/index.spec.js @@ -52,6 +52,8 @@ describe('NgPackagesInstaller', () => { beforeEach(() => { spyOn(installer, '_checkLocalMarker'); + spyOn(installer, '_installDeps'); + spyOn(installer, '_setLocalMarker'); // These are the packages that are "found" in the dist directory dummyNgPackages = { @@ -121,12 +123,20 @@ describe('NgPackagesInstaller', () => { }); describe('when there is a local package marker', () => { + beforeEach(() => installer._checkLocalMarker.and.returnValue(true)); + it('should not continue processing', () => { - installer._checkLocalMarker.and.returnValue(true); installer.installLocalDependencies(); expect(installer._checkLocalMarker).toHaveBeenCalled(); expect(installer._getDistPackages).not.toHaveBeenCalled(); }); + + it('should continue processing (without checking for local marker) if `force` is true', () => { + installer.force = true; + installer.installLocalDependencies(); + expect(installer._checkLocalMarker).not.toHaveBeenCalled(); + expect(installer._getDistPackages).toHaveBeenCalled(); + }); }); describe('when there is no local package marker', () => { @@ -135,8 +145,7 @@ describe('NgPackagesInstaller', () => { beforeEach(() => { log = []; fs.writeFileSync.and.callFake((filePath, contents) => filePath === packageJsonPath && log.push(`writeFile: ${contents}`)); - spyOn(installer, '_installDeps').and.callFake(() => log.push('installDeps:')); - spyOn(installer, '_setLocalMarker'); + installer._installDeps.and.callFake(() => log.push('installDeps:')); installer._checkLocalMarker.and.returnValue(false); installer.installLocalDependencies(); });