1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

fix skeleton

This commit is contained in:
Robin Appelman 2021-03-23 20:00:55 +01:00
commit a77b5c08e9

View file

@ -11,6 +11,7 @@ pub struct Mapping<'a> {
mapping_type: MappingType,
read_only: bool,
map: bool,
create: bool,
}
impl<'a> Mapping<'a> {
@ -30,6 +31,7 @@ impl<'a> Mapping<'a> {
mapping_type: MappingType::Folder,
read_only: false,
map: true,
create: true,
}
}
@ -44,6 +46,13 @@ impl<'a> Mapping<'a> {
Self { map: false, ..self }
}
pub fn dont_create(self) -> Self {
Self {
create: false,
..self
}
}
pub fn file(self) -> Self {
Self {
mapping_type: MappingType::File,
@ -52,6 +61,9 @@ impl<'a> Mapping<'a> {
}
pub async fn create(&self, id: &str, config: &HazeConfig) -> Result<()> {
if !self.create {
return Ok(());
}
let source = match self.source_type {
MappingSourceType::WorkDir => config.work_dir.join(id).join(self.source),
MappingSourceType::GlobalWorkDir => config.work_dir.join(self.source),
@ -93,11 +105,12 @@ pub fn default_mappings() -> Vec<Mapping<'static>> {
Mapping::new(WorkDir, "skeleton", "/var/www/html/core/skeleton"),
Mapping::new(
Sources,
"skeleton/welcome.txt",
"core/skeleton/welcome.txt",
"/var/www/html/core/skeleton/welcome.txt",
)
.file()
.read_only(),
.read_only()
.dont_create(),
Mapping::new(
WorkDir,
"integration/vendor",