Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-leonov committed Mar 29, 2020
1 parent c6f2e74 commit 23c174f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
61 changes: 32 additions & 29 deletions packages/jest-resolve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ const nodePaths = NODE_PATH
: undefined;

function parseOutQuery(pathQithQuery: string) {
const [path, ...queryParts] = pathQithQuery.split('?')
const query = queryParts.join('')
return [path, query]
const [path, ...queryParts] = pathQithQuery.split('?');
const query = queryParts.join('');
return [path, query];
}

/* eslint-disable-next-line no-redeclare */
Expand Down Expand Up @@ -118,7 +118,7 @@ class Resolver {
const paths = options.paths;

try {
const [nativePath, query] = parseOutQuery(path)
const [nativePath, query] = parseOutQuery(path);
const realpath = resolver(nativePath, {
basedir: options.basedir,
browser: options.browser,
Expand All @@ -130,9 +130,9 @@ class Resolver {
});

return {
id: `${realpath}?${query}`,
path: realpath,
id: `${realpath}?${query}`
}
};
} catch (e) {
if (options.throwIfNotFound) {
throw e;
Expand Down Expand Up @@ -176,9 +176,9 @@ class Resolver {
const hasteModule = this.getModule(nativeName);
if (hasteModule) {
const resolvedPath = {
id: `haste:${hasteModule}?${query}`,
path: hasteModule,
id: `haste:${hasteModule}?${query}`
}
};
this._moduleNameCache.set(key, resolvedPath);
return resolvedPath;
}
Expand Down Expand Up @@ -206,7 +206,10 @@ class Resolver {

if (!skipResolution) {
// @ts-ignore: the "pnp" version named isn't in DefinitelyTyped
const nodeModule = resolveNodeModule(moduleName, Boolean(process.versions.pnp));
const nodeModule = resolveNodeModule(
moduleName,
Boolean(process.versions.pnp),
);

if (nodeModule) {
this._moduleNameCache.set(key, nodeModule);
Expand All @@ -220,12 +223,12 @@ class Resolver {
const hastePackage = this.getPackage(parts.shift()!);
if (hastePackage) {
const requireResolve = (name: string) => {
const path = require.resolve(name)
const path = require.resolve(name);
return {
id: `haste:${path}?${query}`,
path,
id: `haste:${path}?${query}`
}
}
};
};
try {
const hastePackageModule = path.join.apply(
path,
Expand All @@ -234,7 +237,8 @@ class Resolver {
// try resolving with custom resolver first to support extensions,
// then fallback to require.resolve
const resolvedModule =
resolveNodeModule(hastePackageModule) || requireResolve(hastePackageModule);
resolveNodeModule(hastePackageModule) ||
requireResolve(hastePackageModule);
this._moduleNameCache.set(key, resolvedModule);
return resolvedModule;
} catch (ignoredError) {}
Expand Down Expand Up @@ -454,28 +458,27 @@ class Resolver {
for (const possibleModuleName of possibleModuleNames) {
const updatedName = mapModuleName(possibleModuleName);

const hasteModule = this.getModule(updatedName)
const hasteModule = this.getModule(updatedName);
if (hasteModule) {
module = {
id: `haste:${hasteModule}?${query}`,
path: hasteModule,
id: `haste:${hasteModule}?${query}`
}
break
};
break;
}

const nodeModule =
Resolver.findNodeModule(updatedName, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths,
resolver,
rootDir: this._options.rootDir,
});
const nodeModule = Resolver.findNodeModule(updatedName, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths,
resolver,
rootDir: this._options.rootDir,
});

if (nodeModule) {
module = nodeModule
module = nodeModule;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ class Runtime {
filename,
id: filename,
loaded: false,
rpth: {id: 'InitialModule', path: filename}
rpth: {id: 'InitialModule', path: filename},
});
};

Expand Down

0 comments on commit 23c174f

Please sign in to comment.