handling PR versions
parent
1f7e48aa46
commit
33c00ca111
|
@ -69,7 +69,12 @@ class Playground extends React.Component {
|
|||
this.state.options
|
||||
);
|
||||
|
||||
this.setState({ loaded: true, availableOptions, options, version });
|
||||
this.setState({
|
||||
loaded: true,
|
||||
availableOptions,
|
||||
options,
|
||||
version: fixPrettierVersion(version)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -192,11 +197,15 @@ class Playground extends React.Component {
|
|||
<ClipboardButton copy={this.getCurrentUrl}>
|
||||
Copy link
|
||||
</ClipboardButton>
|
||||
<ClipboardButton copy={() => this.getMarkdown(formatted, reformatted)}>
|
||||
<ClipboardButton
|
||||
copy={() => this.getMarkdown(formatted, reformatted)}
|
||||
>
|
||||
Copy markdown
|
||||
</ClipboardButton>
|
||||
<LinkButton
|
||||
href={getReportLink(this.getMarkdown(formatted, reformatted, true))}
|
||||
href={getReportLink(
|
||||
this.getMarkdown(formatted, reformatted, true)
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
|
@ -245,6 +254,14 @@ function getSecondFormat(formatted, reformatted) {
|
|||
: reformatted;
|
||||
}
|
||||
|
||||
function fixPrettierVersion(version) {
|
||||
const match = version.match(/^\d+\.\d+\.\d+-pr.(\d+)$/);
|
||||
if (match) {
|
||||
return `pr-${match[1]}`;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
function getDefaultOptions(availableOptions) {
|
||||
return availableOptions.reduce((acc, option) => {
|
||||
acc[option.name] = option.default;
|
||||
|
|
|
@ -4,7 +4,7 @@ import ReactDOM from "react-dom";
|
|||
const root = document.getElementById("version");
|
||||
|
||||
export default function({ version }) {
|
||||
const match = version.match(/^\d+\.\d+\.\d+-.(\d+)$/);
|
||||
const match = version.match(/^pr-(\d+)$/);
|
||||
let href;
|
||||
if (match) {
|
||||
href = `pull/${match[1]}`;
|
||||
|
|
Loading…
Reference in New Issue