Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts multiproc #1603

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
tsparser: fix migrations validation
  • Loading branch information
eandre committed Dec 3, 2024
commit a15350a1442f4782562882ae4d37ce8cbaf3e52e
24 changes: 14 additions & 10 deletions tsparser/src/parser/resources/infra/sqldb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,14 @@ fn visit_dirs(
max_depth: i8,
cb: &mut dyn FnMut(&std::fs::DirEntry) -> ParseResult<()>,
) -> ParseResult<()> {
if dir.is_dir() {
let entries = std::fs::read_dir(dir).map_err(|err| span.parse_err(err.to_string()))?;
for entry in entries {
let entry = entry.map_err(|err| span.parse_err(err.to_string()))?;
let path = entry.path();
if path.is_dir() && depth < max_depth {
visit_dirs(span, &path, depth + 1, max_depth, cb)?;
} else {
cb(&entry)?;
}
let entries = std::fs::read_dir(dir).map_err(|err| span.parse_err(err.to_string()))?;
for entry in entries {
let entry = entry.map_err(|err| span.parse_err(err.to_string()))?;
let path = entry.path();
if path.is_dir() && depth < max_depth {
visit_dirs(span, &path, depth + 1, max_depth, cb)?;
} else {
cb(&entry)?;
}
}
Ok(())
Expand Down Expand Up @@ -356,6 +354,12 @@ fn parse_migrations(
dir: &Path,
source: Option<&MigrationFileSource>,
) -> ParseResult<Vec<DBMigration>> {
if !dir.exists() {
return Err(span.parse_err("migrations directory does not exist"));
} else if !dir.is_dir() {
return Err(span.parse_err("migrations path is not a directory"));
}

let mut migrations = match source {
Some(MigrationFileSource::Drizzle) => parse_drizzle(span, dir),
Some(MigrationFileSource::Prisma) => parse_prisma(span, dir),
Expand Down
Loading