mirror of https://github.com/status-im/metro.git
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
This commit is contained in:
parent
f4fc79ab68
commit
1a547cc2b1
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -41,6 +41,10 @@ class ModuleCache {
|
|||
return this._moduleCache[filePath];
|
||||
}
|
||||
|
||||
getAllModules() {
|
||||
return this._moduleCache;
|
||||
}
|
||||
|
||||
getAssetModule(filePath) {
|
||||
filePath = path.resolve(filePath);
|
||||
if (!this._moduleCache[filePath]) {
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.autoMockOff();
|
||||
jest.autoMockOff()
|
||||
.dontMock('graceful-fs');
|
||||
|
||||
const Fastfs = require('../fastfs');
|
||||
|
||||
|
|
Loading…
Reference in New Issue