-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore callerDependency to it's original state. Create a mock caller…
…Dependency and add mockery to handle properly requiring the mock instead of the original callerDependency.
- Loading branch information
Showing
5 changed files
with
28 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 17 additions & 3 deletions
20
packages/react-server-cli/src/__tests__/compileClient/compileClientSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import lookup from "look-up"; | ||
import path from "path"; | ||
|
||
export default function callerDependency(dep) { | ||
// TODO: We should grab stuff based on what the routes file would get out | ||
// of `require.resolve(dep)`. Using `process.cwd()` instead for now. | ||
return lookup("packages/" + dep, {cwd: path.resolve(process.cwd() + '/..')}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
import lookup from "look-up"; | ||
import path from "path"; | ||
|
||
// NOTE: if this function changes, make sure it also changes in the 'callerDependency-Mock.js' file as well. | ||
export default function callerDependency(dep) { | ||
// TODO: We should grab stuff based on what the routes file would get out | ||
// of `require.resolve(dep)`. Using `process.cwd()` instead for now. | ||
let cwd = process.cwd(), | ||
lookupResult; | ||
|
||
if (process.env.NODE_ENV === '__react-server-cli-unit-test__') { // eslint-disable-line no-process-env | ||
cwd = path.resolve(cwd + '/..'); | ||
lookupResult = lookup("packages/" + dep, {cwd: cwd}); | ||
} else { | ||
lookupResult = lookup("node_modules/" + dep, {cwd: cwd}); | ||
} | ||
return lookupResult; | ||
return lookup("node_modules/" + dep, {cwd: process.cwd()}); | ||
} |