-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Load custom formatter by relative path only if it begins with a dot #1413
Merged
davidjgoss
merged 6 commits into
cucumber:master
from
dawn-minion:issue_1412_formatter_path
Nov 26, 2020
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b8839e
Load formatter by rel path only if starts with .
dawn-minion 4bb5a34
Add note about this change to CHANGELOG breaking changes
dawn-minion 91dbe2d
Add YarnPNP to feature changelog, switch to create-require
dawn-minion 54f2c6a
Change wording of custom formatter path change
dawn-minion 47d0a8c
Make CustomFormatter const
dawn-minion 36b2823
Bump create-require to 1.1.1 and remove dom from tsconfig
dawn-minion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,6 +20,7 @@ import { Writable as WritableStream } from 'stream' | |||||||||
import { IParsedArgvFormatOptions } from '../cli/argv_parser' | ||||||||||
import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax' | ||||||||||
import HtmlFormatter from './html_formatter' | ||||||||||
import createRequire from 'create-require' | ||||||||||
|
||||||||||
interface IGetStepDefinitionSnippetBuilderOptions { | ||||||||||
cwd: string | ||||||||||
|
@@ -107,8 +108,10 @@ const FormatterBuilder = { | |||||||||
}, | ||||||||||
|
||||||||||
loadCustomFormatter(customFormatterPath: string, cwd: string) { | ||||||||||
const fullCustomFormatterPath = path.resolve(cwd, customFormatterPath) | ||||||||||
const CustomFormatter = require(fullCustomFormatterPath) // eslint-disable-line @typescript-eslint/no-var-requires | ||||||||||
let CustomFormatter = null | ||||||||||
|
||||||||||
CustomFormatter = createRequire(cwd)(customFormatterPath) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||||||||||
|
||||||||||
if (typeof CustomFormatter === 'function') { | ||||||||||
return CustomFormatter | ||||||||||
} else if ( | ||||||||||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: They are always loaded relative to the cwd now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the note being that it uses the regular require search path relative to cwd now, instead of always trying to load a file by path from the cwd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully that's a bit clearer now.