-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
format scaffolded project after creation and check in e2e
- Loading branch information
1 parent
d27c29f
commit 6ad3205
Showing
3 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import chalk from "chalk"; | ||
import { execa } from "execa"; | ||
import ora from "ora"; | ||
|
||
import type { PackageManager } from "~/utils/getUserPkgManager.js"; | ||
import { logger } from "~/utils/logger.js"; | ||
|
||
// Runs format and lint command to ensure created repository is tidy upon creation | ||
export const formatProject = async ({ | ||
pkgManager, | ||
projectDir, | ||
eslint, | ||
biome, | ||
}: { | ||
pkgManager: PackageManager; | ||
projectDir: string; | ||
eslint: boolean; | ||
biome: boolean; | ||
}) => { | ||
logger.info("Formatting project..."); | ||
const spinner = ora("Running format command\n").start(); | ||
|
||
if (eslint) { | ||
await execa(pkgManager, ["format:write"], { | ||
cwd: projectDir, | ||
}); | ||
} else if (biome) { | ||
await execa(pkgManager, ["check:unsafe"], { | ||
cwd: projectDir, | ||
}); | ||
} | ||
spinner.succeed(`${chalk.green("Successfully formatted project")}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters