Revert "Do not use now-examples anymore"

This reverts commit fdb74b7971.
This commit is contained in:
Andy Bitz
2020-01-09 17:28:49 +01:00
parent fdb74b7971
commit ac72e944a7
2 changed files with 17 additions and 4 deletions

View File

@@ -51,9 +51,15 @@ export default withApiHandler(async function(req: NowRequest, res: NowResponse)
await extract('https://github.com/zeit/now-examples/archive/7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3.zip', TMP_DIR); await extract('https://github.com/zeit/now-examples/archive/7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3.zip', TMP_DIR);
directory = `${TMP_DIR}/now-examples-7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3/${example}`; directory = `${TMP_DIR}/now-examples-7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3/${example}`;
} else { } else {
await extract('https://github.com/zeit/now-examples/archive/master.zip', TMP_DIR);
directory = `${TMP_DIR}/now-examples-master/${example}`;
if (!isDirectory(directory)) {
// Use `now` instead of `now-examples` if the searched example does not exist
await extract('https://github.com/zeit/now/archive/master.zip', TMP_DIR); await extract('https://github.com/zeit/now/archive/master.zip', TMP_DIR);
directory = `${TMP_DIR}/now-master/examples/${example}`; directory = `${TMP_DIR}/now-master/examples/${example}`;
} }
}
if (!isDirectory(directory)) { if (!isDirectory(directory)) {
return notFound(res, `Example '${example}' was not found.`); return notFound(res, `Example '${example}' was not found.`);

View File

@@ -20,8 +20,15 @@ export default withApiHandler(async function(
return res.send(exampleList); return res.send(exampleList);
} }
await extract('https://github.com/zeit/now/archive/master.zip', '/tmp'); await Promise.all([
const exampleList = summary('/tmp/now-master/examples'); extract('https://github.com/zeit/now/archive/master.zip', '/tmp'),
extract('https://github.com/zeit/now-examples/archive/master.zip', '/tmp'),
]);
const exampleList = new Set([
...summary('/tmp/now-master/examples'),
...summary('/tmp/now-examples-master'),
]);
const existingExamples = Array.from(exampleList).map(key => ({ const existingExamples = Array.from(exampleList).map(key => ({
name: key, name: key,