From db275dd49f2031a6d5d3db36fafb386645349b5e Mon Sep 17 00:00:00 2001 From: Christoph Pojer Date: Mon, 1 Feb 2016 18:26:30 -0800 Subject: [PATCH] Updates from GitHub Summary: This syncs a couple of changes from GitHub that are necessary for jest: * Expose `set` on Cache * Add a function to `getAllModules` from the graph * Explicitly dontMock `graceful-fs` in the fastfs test. node-haste2 has this manual mock which is still used in automocked tests (ugh!). public Reviewed By: davidaurelio Differential Revision: D2885112 fb-gh-sync-id: b2060d5474ebee5aa13e6ba2bdf5879b46f3fd5f --- packager/react-packager/src/DependencyResolver/Cache/index.js | 4 ++-- .../src/DependencyResolver/DependencyGraph/index.js | 4 ++++ packager/react-packager/src/DependencyResolver/ModuleCache.js | 4 ++++ .../DependencyResolver/__tests__/fastfs-integrated-test.js | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packager/react-packager/src/DependencyResolver/Cache/index.js b/packager/react-packager/src/DependencyResolver/Cache/index.js index 06d346d62..4e1698cb3 100644 --- a/packager/react-packager/src/DependencyResolver/Cache/index.js +++ b/packager/react-packager/src/DependencyResolver/Cache/index.js @@ -53,7 +53,7 @@ class Cache { var recordP = this.has(filepath, field) ? this._data[filepath].data[field] - : this._set(filepath, field, loaderCb(filepath)); + : this.set(filepath, field, loaderCb(filepath)); return recordP.then(record => record); } @@ -77,7 +77,7 @@ class Cache { (field == null || Object.prototype.hasOwnProperty.call(this._data[filepath].data, field)); } - _set(filepath, field, loaderPromise) { + set(filepath, field, loaderPromise) { let record = this._data[filepath]; if (!record) { record = Object.create(null); diff --git a/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js b/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js index ed09f91ad..bc5d85d78 100644 --- a/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js +++ b/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js @@ -158,6 +158,10 @@ class DependencyGraph { return this._moduleCache.getModule(entryFile); } + getAllModules() { + return this.load().then(() => this._moduleCache.getAllModules()); + } + getDependencies(entryPath, platform, recursive = true) { return this.load().then(() => { platform = this._getRequestPlatform(entryPath, platform); diff --git a/packager/react-packager/src/DependencyResolver/ModuleCache.js b/packager/react-packager/src/DependencyResolver/ModuleCache.js index fac1820b8..3fcfb173a 100644 --- a/packager/react-packager/src/DependencyResolver/ModuleCache.js +++ b/packager/react-packager/src/DependencyResolver/ModuleCache.js @@ -41,6 +41,10 @@ class ModuleCache { return this._moduleCache[filePath]; } + getAllModules() { + return this._moduleCache; + } + getAssetModule(filePath) { filePath = path.resolve(filePath); if (!this._moduleCache[filePath]) { diff --git a/packager/react-packager/src/DependencyResolver/__tests__/fastfs-integrated-test.js b/packager/react-packager/src/DependencyResolver/__tests__/fastfs-integrated-test.js index f7fb35588..cbff314af 100644 --- a/packager/react-packager/src/DependencyResolver/__tests__/fastfs-integrated-test.js +++ b/packager/react-packager/src/DependencyResolver/__tests__/fastfs-integrated-test.js @@ -8,7 +8,8 @@ */ 'use strict'; -jest.autoMockOff(); +jest.autoMockOff() + .dontMock('graceful-fs'); const Fastfs = require('../fastfs');