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

Temp changes to check semgrep failure #1493

Closed
wants to merge 3 commits into from
Closed
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
11 changes: 8 additions & 3 deletions packages/core/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ export function createPercyServer(percy, port) {
})
// post one or more comparisons, optionally waiting
.route('post', '/percy/comparison', async (req, res) => {
let upload = percy.upload(req.body);
if (req.url.searchParams.has('await')) await upload;
if (percy.syncMode(req.body)) {
const snapshotPromise = new Promise((resolve, reject) => percy.upload(req.body, { resolve, reject }));
await snapshotPromise;
} else {
let upload = percy.upload(req.body);
if (req.url.searchParams.has('await')) await upload;
}

// generate and include one or more redirect links to comparisons
let link = ({ name, tag }) => [
Expand All @@ -108,7 +113,7 @@ export function createPercyServer(percy, port) {
}, { snake: true }))
].join('');

return res.json(200, Object.assign({ success: true }, req.body ? (
return res.json(200, Object.assign({ success: false }, req.body ? (
Array.isArray(req.body) ? { links: req.body.map(link) } : { link: link(req.body) }
) : {}));
})
Expand Down