Skip to content

Commit dcd4406

Browse files
committed
fix: create-package script
1 parent 3b94a7c commit dcd4406

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/create-package/utils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@ export async function finalizeAndWriteData(
9494
monorepoFileData: MonorepoFileData,
9595
) {
9696
const packagePath = path.join(PACKAGES_PATH, packageData.directoryName);
97-
if ((await fs.stat(packagePath)).isDirectory()) {
98-
throw new Error(`The package directory already exists: ${packagePath}`);
97+
try {
98+
if ((await fs.stat(packagePath)).isDirectory()) {
99+
throw new Error(`The package directory already exists: ${packagePath}`);
100+
}
101+
} catch (error) {
102+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
103+
throw error;
104+
}
99105
}
100106

101107
console.log('Writing package and monorepo files...');
@@ -136,7 +142,7 @@ async function writeJsonFile(
136142
): Promise<void> {
137143
await fs.writeFile(
138144
filePath,
139-
prettierFormat(fileContent, { ...prettierRc, parser: 'json' }),
145+
await prettierFormat(fileContent, { ...prettierRc, parser: 'json' }),
140146
);
141147
}
142148

0 commit comments

Comments
 (0)