Skip to content

Commit 3dbe28c

Browse files
committed
feat(create-email): remove the starter directory if it fails to get the versions
1 parent 94a968d commit 3dbe28c

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

packages/create-email/src/index.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,24 @@ const init = async (name, { tag }) => {
6666
'./package.json',
6767
);
6868
const templatePackageJson = fse.readFileSync(templatePackageJsonPath, 'utf8');
69-
fse.writeFileSync(
70-
templatePackageJsonPath,
71-
templatePackageJson
72-
.replace(
73-
'INSERT_COMPONENTS_VERSION',
74-
await getLatestVersionOfTag('@react-email/components', tag),
75-
)
76-
.replace(
77-
'INSERT_REACT_EMAIL_VERSION',
78-
await getLatestVersionOfTag('react-email', tag),
79-
),
80-
'utf8',
81-
);
69+
try {
70+
fse.writeFileSync(
71+
templatePackageJsonPath,
72+
templatePackageJson
73+
.replace(
74+
'INSERT_COMPONENTS_VERSION',
75+
await getLatestVersionOfTag('@react-email/components', tag),
76+
)
77+
.replace(
78+
'INSERT_REACT_EMAIL_VERSION',
79+
await getLatestVersionOfTag('react-email', tag),
80+
),
81+
'utf8',
82+
);
83+
} catch (exception) {
84+
fse.removeSync(resolvedProjectPath);
85+
throw exception;
86+
}
8287

8388
spinner.stopAndPersist({
8489
symbol: logSymbols.success,

0 commit comments

Comments
 (0)