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