Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolving against the working directory in legacy API #212

Merged
merged 2 commits into from
Apr 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/src/legacy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ function adjustOptions<sync extends 'sync' | 'async'>(
throw new Error('Either options.data or options.file must be set.');
}

// In legacy API, the current working directory is always attempted before
// any load path.
options.includePaths = [process.cwd(), ...(options.includePaths ?? [])];

if (
!isStringOptions(options) &&
// The `indentedSyntax` option takes precedence over the file extension in the
Expand Down Expand Up @@ -200,9 +204,7 @@ function pluginThis(
context: undefined as unknown as LegacyPluginThis,
file: options.file,
data: options.data,
includePaths: [process.cwd(), ...(options.includePaths ?? [])].join(
p.delimiter
),
includePaths: (options.includePaths ?? []).join(p.delimiter),
precision: 10,
style: 1,
indentType: 0,
Expand Down