Skip to content

Commit

Permalink
Build: Only publish once per generate-repros-next run
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Aug 23, 2022
1 parent 0e025c5 commit ffecbd1
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions scripts/next-repro-generators/generate-repros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,11 @@ const sbInit = async (cwd: string) => {
const LOCAL_REGISTRY_URL = 'http://localhost:6001';
const withLocalRegistry = async (packageManager: JsPackageManager, action: () => Promise<void>) => {
const prevUrl = packageManager.getRegistryURL();
let controller: AbortController;
try {
// @ts-ignore
await publish.run();
console.log(`⚙️ Starting local registry: ${LOCAL_REGISTRY_URL}`);
controller = await servePackages({});

console.log(`📦 Configuring local registry: ${LOCAL_REGISTRY_URL}`);
packageManager.setRegistryURL(LOCAL_REGISTRY_URL);
await action();
} finally {
if (controller) {
console.log(`🛑 Stopping local registry: ${LOCAL_REGISTRY_URL}`);
controller.abort();
}
console.log(`📦 Restoring registry: ${prevUrl}`);
packageManager.setRegistryURL(prevUrl);
}
Expand Down Expand Up @@ -115,7 +105,15 @@ const runGenerators = async (

const limit = pLimit(maxConcurrentTasks);

return Promise.all(
let controller: AbortController;
if (localRegistry) {
// @ts-ignore
await publish.run();
console.log(`⚙️ Starting local registry: ${LOCAL_REGISTRY_URL}`);
controller = await servePackages({ debug: true });
}

await Promise.all(
generators.map(({ dirName, name, script }) =>
limit(async () => {
const time = process.hrtime();
Expand Down Expand Up @@ -146,6 +144,12 @@ const runGenerators = async (
})
)
);

if (controller) {
console.log(`🛑 Stopping local registry: ${LOCAL_REGISTRY_URL}`);
controller.abort();
console.log(`✅ Stopped`);
}
};

const generate = async ({
Expand Down

0 comments on commit ffecbd1

Please sign in to comment.