Merge pull request #127 from strongloop/refactor/tryResolveAppPath
Clean up compiler.tryResolveAppPath
This commit is contained in:
commit
a2000829bc
|
@ -272,7 +272,7 @@ function findModelDefinitions(rootDir, sources) {
|
|||
var registry = {};
|
||||
|
||||
sources.forEach(function(src) {
|
||||
var srcDir = tryResolveAppPath(rootDir, src);
|
||||
var srcDir = tryResolveAppPath(rootDir, src, { strict: false });
|
||||
if (!srcDir) {
|
||||
debug('Skipping unknown module source dir %j', src);
|
||||
return;
|
||||
|
@ -314,13 +314,14 @@ function tryResolveAppPath(rootDir, relativePath, resolveOptions) {
|
|||
var fullPath;
|
||||
var start = relativePath.substring(0, 2);
|
||||
|
||||
/* In order to retain backward compatibility, while resolving
|
||||
* component path, `resolveOptions` parameter is added where
|
||||
* `resolveOptions.strict` = true,
|
||||
* means retain backward compatibility when resolving the path and
|
||||
* `resolveOptions.strict` = false,
|
||||
* does not enforce any such restriction when resolving the path */
|
||||
resolveOptions = resolveOptions || { strict: false };
|
||||
/* In order to retain backward compatibility, we need to support
|
||||
* two ways how to treat values that are not relative nor absolute
|
||||
* path (e.g. `relativePath = 'foobar'`)
|
||||
* - `resolveOptions.strict = true` searches in `node_modules` only
|
||||
* - `resolveOptions.strict = false` attempts to resolve the value
|
||||
* as a relative path first before searching `node_modules`
|
||||
*/
|
||||
resolveOptions = resolveOptions || { strict: true };
|
||||
|
||||
var isModuleRelative = false;
|
||||
if (relativePath[0] === '/') {
|
||||
|
@ -535,8 +536,9 @@ function buildComponentInstructions(rootDir, componentConfig) {
|
|||
}
|
||||
|
||||
function resolveRelativePaths(relativePaths, appRootDir) {
|
||||
var resolveOpts = { strict: false };
|
||||
relativePaths.forEach(function(relativePath, k) {
|
||||
var resolvedPath = tryResolveAppPath(appRootDir, relativePath);
|
||||
var resolvedPath = tryResolveAppPath(appRootDir, relativePath, resolveOpts);
|
||||
if (resolvedPath !== undefined) {
|
||||
relativePaths[k] = resolvedPath;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue