-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: force resolveRoot to return relative paths for machine-agnostic…
… snapshots
- Loading branch information
1 parent
c83d778
commit ae6b2f2
Showing
4 changed files
with
376 additions
and
365 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import path from "path" | ||
|
||
export function resolveRoot(id: string, root: string): string { | ||
const isPath = id.startsWith('.') || id.startsWith('/') | ||
// resolve the package.json of a plugin as many plugins don't have valid | ||
// entrypoints now that we're intending their tasks/hooks to be loaded via | ||
// entrypoints defined in config | ||
const modulePath = isPath ? id : path.join(id, 'package.json') | ||
const resolvedPath = require.resolve(modulePath, { paths: [root] }) | ||
return path.dirname(resolvedPath) | ||
} |
Oops, something went wrong.