Skip to content

Commit

Permalink
Merge pull request #27515 from storybookjs/valentin/fix-sandbox-gener…
Browse files Browse the repository at this point in the history
…ation-2

Build: Fix tempy usage during sandbox generation
  • Loading branch information
valentinpalkovic committed Jun 3, 2024
2 parents 9b12305 + 6f9ff5e commit 183ac32
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions scripts/sandbox/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,22 @@ if (!existsSync(REPROS_DIRECTORY)) {
throw Error("Couldn't find sandbox directory. Did you forget to run generate-sandboxes?");
}

const { temporaryDirectory } = await import('tempy');
const tmpFolder = temporaryDirectory();
logger.log(`⏱ Created tmp folder: ${tmpFolder}`);

const options = program.opts() as PublishOptions;

publish({ ...options, tmpFolder }).catch(async (e) => {
logger.error(e);
async function main() {
const { temporaryDirectory } = await import('tempy');
const tmpFolder = temporaryDirectory();
logger.log(`⏱ Created tmp folder: ${tmpFolder}`);

const options = program.opts() as PublishOptions;

publish({ ...options, tmpFolder }).catch(async (e) => {
logger.error(e);

if (existsSync(tmpFolder)) {
logger.log('🚮 Removing the temporary folder..');
await remove(tmpFolder);
}
process.exit(1);
});
}

if (existsSync(tmpFolder)) {
logger.log('🚮 Removing the temporary folder..');
await remove(tmpFolder);
}
process.exit(1);
});
main();

0 comments on commit 183ac32

Please sign in to comment.