metro-file-map
Advanced tools
Comparing version 0.72.0 to 0.72.1
{ | ||
"name": "metro-file-map", | ||
"version": "0.72.0", | ||
"version": "0.72.1", | ||
"description": "[Experimental] - 🚇 File crawling, watching and mapping for Metro", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -33,3 +33,2 @@ "use strict"; | ||
*/ | ||
// $FlowFixMe[missing-export] - serialize and deserialize missing typedefs | ||
const DEFAULT_PREFIX = "metro-file-map"; | ||
@@ -36,0 +35,0 @@ const DEFAULT_DIRECTORY = (0, _os.tmpdir)(); |
@@ -94,4 +94,8 @@ "use strict"; | ||
(error, response) => { | ||
if (error) { | ||
reject(error); | ||
if (error != null || response == null) { | ||
reject( | ||
error !== null && error !== void 0 | ||
? error | ||
: new Error("capabilityCheck: Response missing") | ||
); | ||
} else { | ||
@@ -283,3 +287,3 @@ resolve(response); | ||
let queryGenerator = undefined; | ||
let queryGenerator; | ||
@@ -357,2 +361,3 @@ if (since != null) { | ||
let isFresh = false; | ||
let queryError; | ||
@@ -371,11 +376,52 @@ try { | ||
results = watchmanFileResults.results; | ||
} finally { | ||
client.end(); | ||
} catch (e) { | ||
queryError = e; | ||
} | ||
if (clientError) { | ||
client.end(); | ||
if (results == null) { | ||
var _ref, _queryError; | ||
if (clientError) { | ||
var _clientError$message; | ||
perfLogger === null || perfLogger === void 0 | ||
? void 0 | ||
: perfLogger.annotate({ | ||
string: { | ||
"watchmanCrawl/client_error": | ||
(_clientError$message = clientError.message) !== null && | ||
_clientError$message !== void 0 | ||
? _clientError$message | ||
: "[message missing]", | ||
}, | ||
}); | ||
} | ||
if (queryError) { | ||
var _queryError$message; | ||
perfLogger === null || perfLogger === void 0 | ||
? void 0 | ||
: perfLogger.annotate({ | ||
string: { | ||
"watchmanCrawl/query_error": | ||
(_queryError$message = queryError.message) !== null && | ||
_queryError$message !== void 0 | ||
? _queryError$message | ||
: "[message missing]", | ||
}, | ||
}); | ||
} | ||
perfLogger === null || perfLogger === void 0 | ||
? void 0 | ||
: perfLogger.point("watchmanCrawl_end"); | ||
throw clientError; | ||
throw (_ref = | ||
(_queryError = queryError) !== null && _queryError !== void 0 | ||
? _queryError | ||
: clientError) !== null && _ref !== void 0 | ||
? _ref | ||
: new Error("Watchman file results missing"); | ||
} | ||
@@ -382,0 +428,0 @@ |
@@ -12,2 +12,4 @@ "use strict"; | ||
var path = _interopRequireWildcard(require("path")); | ||
var _jestUtil = require("jest-util"); | ||
@@ -70,3 +72,2 @@ | ||
*/ | ||
// $FlowFixMe[untyped-import] - jest-util | ||
class HasteFS { | ||
@@ -146,3 +147,39 @@ constructor({ rootDir, files }) { | ||
} | ||
/** | ||
* Given a search context, return a list of file paths matching the query. | ||
* The query matches against normalized paths which start with `./`, | ||
* for example: `a/b.js` -> `./a/b.js` | ||
*/ | ||
matchFilesWithContext(root, context) { | ||
const files = []; | ||
const prefix = "./"; | ||
for (const file of this.getAbsoluteFileIterator()) { | ||
const filePath = fastPath.relative(root, file); | ||
const isUnderRoot = filePath && !filePath.startsWith(".."); // Ignore everything outside of the provided `root`. | ||
if (!isUnderRoot) { | ||
continue; | ||
} // Prevent searching in child directories during a non-recursive search. | ||
if (!context.recursive && filePath.includes(path.sep)) { | ||
continue; | ||
} | ||
if ( | ||
context.filter.test( | ||
// NOTE(EvanBacon): Ensure files start with `./` for matching purposes | ||
// this ensures packages work across Metro and Webpack (ex: Storybook for React DOM / React Native). | ||
// `a/b.js` -> `./a/b.js` | ||
prefix + filePath.replace(/\\/g, "/") | ||
) | ||
) { | ||
files.push(file); | ||
} | ||
} | ||
return files; | ||
} | ||
matchFilesWithGlob(globs, root) { | ||
@@ -149,0 +186,0 @@ const files = new Set(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227312
4095