| 1980 | * @returns {void} |
| 1981 | */ |
| 1982 | const resolveFile = (path, symbol, resolve) => { |
| 1983 | const key = `${symbol}\n${context}\n${path}`; |
| 1984 | if (resolveResults.has(key)) { |
| 1985 | return callback(); |
| 1986 | } |
| 1987 | resolveResults.set(key, undefined); |
| 1988 | /** @type {ResolveFunctionAsync} */ |
| 1989 | (resolve)( |
| 1990 | /** @type {string} */ (context), |
| 1991 | path, |
| 1992 | resolverContext, |
| 1993 | (err, _, result) => { |
| 1994 | if (typeof expected === "string") { |
| 1995 | if (!err && result && result.path === expected) { |
| 1996 | resolveResults.set(key, result.path); |
| 1997 | } else { |
| 1998 | invalidResolveResults.add(key); |
| 1999 | logger.warn( |
| 2000 | `Resolving '${path}' in ${context} for build dependencies doesn't lead to expected result '${expected}', but to '${ |
| 2001 | err || (result && result.path) |
| 2002 | }' instead. Resolving dependencies are ignored for this path.\n${pathToString( |
| 2003 | job |
| 2004 | )}` |
| 2005 | ); |
| 2006 | } |
| 2007 | } else { |
| 2008 | if (err) { |
| 2009 | if (expected === false) { |
| 2010 | resolveResults.set(key, false); |
| 2011 | return callback(); |
| 2012 | } |
| 2013 | invalidResolveResults.add(key); |
| 2014 | err.message += `\nwhile resolving '${path}' in ${context} as file\n${pathToString( |
| 2015 | job |
| 2016 | )}`; |
| 2017 | return callback(err); |
| 2018 | } |
| 2019 | const resultPath = /** @type {ResolveRequest} */ (result).path; |
| 2020 | resolveResults.set(key, resultPath); |
| 2021 | push({ |
| 2022 | type: RBDT_FILE, |
| 2023 | context: undefined, |
| 2024 | path: /** @type {string} */ (resultPath), |
| 2025 | expected: undefined, |
| 2026 | issuer: job |
| 2027 | }); |
| 2028 | } |
| 2029 | callback(); |
| 2030 | } |
| 2031 | ); |
| 2032 | }; |
| 2033 | const resolvedType = |
| 2034 | type === RBDT_RESOLVE_INITIAL |
| 2035 | ? /[\\/]$/.test(path) |