refactor: build one binary instead of a library and a binary

This commit is contained in:
2026-09-08 11:26:33 +00:00
parent 27c6b261a6
commit 056da8b9b2
6 changed files with 21 additions and 69 deletions

View File

@@ -1,4 +1,4 @@
use std::fs::create_dir;
use std::fs::{File, OpenOptions, create_dir};
use std::io::Write;
use std::path::{Path, PathBuf};
@@ -6,7 +6,6 @@ use anyhow::{Result, anyhow};
use crate::compose::Compose;
use crate::scripts::docker_compose;
use crate::{create_file, safe_create_file};
const DEBUG_TEMPLATE: &str = r#"from django.core.management.base import BaseCommand
@@ -89,3 +88,17 @@ pub fn shell() -> Result<()> {
pub fn test() -> Result<()> {
manage(&["test".to_string()])
}
fn safe_create_file(path: PathBuf) -> Result<File, std::io::Error> {
OpenOptions::new().write(true).create_new(true).open(path)
}
// truncate(false) keeps an existing file's contents, which is what callers creating
// an empty __init__.py want
fn create_file(path: PathBuf) -> Result<File, std::io::Error> {
OpenOptions::new()
.write(true)
.create(true)
.truncate(false)
.open(path)
}