diff --git a/index.js b/index.js index 8f2e570..2acfdba 100644 --- a/index.js +++ b/index.js @@ -163,7 +163,7 @@ function init (options) { // above the node_modules directory, // Or that package.json is in the node process' current working directory (when // running a package manager script, e.g. `yarn start` / `npm run start`) - candidatePackagePaths = [nodePath.join(__dirname, '../..'), process.cwd()] + candidatePackagePaths = [process.cwd(), nodePath.join(__dirname, '../..')] } var npmPackage diff --git a/test/specs.js b/test/specs.js index 4793827..d1b2783 100644 --- a/test/specs.js +++ b/test/specs.js @@ -151,6 +151,8 @@ describe('module-alias', function () { }) it('should import default settings from ../../package.json', function () { + process.chdir(moduleAliasDir) + linkedModuleAlias() expectAliasesToBeImported() diff --git a/test/src/node_modules/module-alias/package.json b/test/src/node_modules/module-alias/package.json new file mode 100644 index 0000000..a072a27 --- /dev/null +++ b/test/src/node_modules/module-alias/package.json @@ -0,0 +1,10 @@ +{ + "name": "test-app", + "_moduleDirectories": ["../../node_modules_custom"], + "_moduleAliases": { + "@src": "../..", + "@foo": "../../foo/index.js", + "@bar": "../../bar", + "some/foo": "../../foo" + } +}