Skip to content

Commit

Permalink
Delete cache folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun Lloyd committed Dec 5, 2023
1 parent a9d54ca commit f3766dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
1 change: 1 addition & 0 deletions code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ async function doInitiate(
projectType === ProjectType.ANGULAR
? `ng run ${installResult.projectName}:storybook`
: packageManager.getRunStorybookCommand();

logger.log(
boxen(
dedent`
Expand Down
28 changes: 8 additions & 20 deletions code/lib/cli/src/scaffold-new-project.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import boxen from 'boxen';
import chalk from 'chalk';
import execa from 'execa';
import { readdirSync, existsSync, move } from 'fs-extra';
import { readdirSync, remove } from 'fs-extra';
import prompts from 'prompts';
import * as tempy from 'tempy';
import dedent from 'ts-dedent';

import { GenerateNewProjectOnInitError } from '@storybook/core-events/server-errors';
Expand Down Expand Up @@ -159,32 +158,26 @@ export const scaffoldNewProject = async (packageManager: PackageManagerName) =>
const projectDisplayName = buildProjectDisplayNameForPrint(projectStrategy);
const createScript = projectStrategy.createScript[packageManagerName];

const tempDir = tempy.directory();
const targetDir = process.cwd();

logger.line(1);
logger.plain(
`Creating a new "${projectDisplayName}" project with ${chalk.bold(packageManagerName)}...`
);
logger.line(1);

const targetDir = process.cwd();

try {
// If target directory has a .cache folder, remove it
// so that it does not block the creation of the new project
await remove(`${targetDir}/.cache`);

// Create new project in temp directory
await execa.command(createScript, {
stdio: 'pipe',
shell: true,
cwd: tempDir,
cwd: targetDir,
cleanup: true,
});

// If target directory has a .cache folder, move it to temp directory
// so that it's not overwritten by the move operation below
if (existsSync(`${targetDir}/.cache`)) {
await move(`${targetDir}/.cache`, `${tempDir}/.cache`);
}

// Move temp directory to target directory
await move(`${tempDir}`, targetDir, { overwrite: true });
} catch (e) {
throw new GenerateNewProjectOnInitError({
error: e,
Expand Down Expand Up @@ -223,11 +216,6 @@ export const currentDirectoryIsEmpty = (packageManager: PackageManagerName) => {
const packageManagerName = packageManagerToCoercedName(packageManager);
const cwdFolderEntries = readdirSync(process.cwd());

if (process.env.DEBUG) {
console.log('CWD entries:');
console.log(cwdFolderEntries);
}

const filesToIgnore = IGNORED_FILES_BY_PACKAGE_MANAGER[packageManagerName];

return (
Expand Down

0 comments on commit f3766dc

Please sign in to comment.