copy pack.png to output in build and package subcommand
This commit is contained in:
parent
41416ffc38
commit
3c279083c7
|
@ -24,7 +24,7 @@ colored = "2.1.0"
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
thiserror = "1.0.58"
|
thiserror = "1.0.58"
|
||||||
toml = "0.8.12"
|
toml = "0.8.12"
|
||||||
shulkerscript-lang = { git = "https://github.com/moritz-hoelting/shulkerscript-lang", features = ["shulkerbox"], default-features = false, rev = "44d634355b4ab5b652de56b0becd61b05680c068"}
|
shulkerscript-lang = { git = "https://github.com/moritz-hoelting/shulkerscript-lang", features = ["shulkerbox"], default-features = false, rev = "899a973315ce63ff20c789a7e7a784e926efc027"}
|
||||||
shulkerbox = { git = "https://github.com/moritz-hoelting/shulkerbox", default-features = false, rev = "b79c9ecd6d45f9319c9083a8103ef0186839b0c0" }
|
shulkerbox = { git = "https://github.com/moritz-hoelting/shulkerbox", default-features = false, rev = "b79c9ecd6d45f9319c9083a8103ef0186839b0c0" }
|
||||||
git2 = { version = "0.18.3", default-features = false }
|
git2 = { version = "0.18.3", default-features = false }
|
||||||
path-absolutize = "3.1.1"
|
path-absolutize = "3.1.1"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use path_absolutize::Absolutize;
|
use path_absolutize::Absolutize;
|
||||||
use shulkerbox::virtual_fs::VFolder;
|
use shulkerbox::virtual_fs::{VFile, VFolder};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::ProjectConfig,
|
config::ProjectConfig,
|
||||||
|
@ -40,12 +40,6 @@ pub fn build(_verbose: bool, args: &BuildArgs) -> Result<()> {
|
||||||
path.absolutize()?.display()
|
path.absolutize()?.display()
|
||||||
));
|
));
|
||||||
|
|
||||||
// env::set_current_dir(
|
|
||||||
// toml_path
|
|
||||||
// .parent()
|
|
||||||
// .expect("Failed to get parent directory of pack.toml"),
|
|
||||||
// )?;
|
|
||||||
|
|
||||||
let (project_config, toml_path) = get_pack_config(path)?;
|
let (project_config, toml_path) = get_pack_config(path)?;
|
||||||
|
|
||||||
let script_paths = get_script_paths(
|
let script_paths = get_script_paths(
|
||||||
|
@ -55,7 +49,15 @@ pub fn build(_verbose: bool, args: &BuildArgs) -> Result<()> {
|
||||||
.join("src"),
|
.join("src"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let compiled = shulkerscript_lang::compile(&script_paths)?;
|
let mut compiled = shulkerscript_lang::compile(&script_paths)?;
|
||||||
|
|
||||||
|
let icon_path = toml_path.parent().unwrap().join("pack.png");
|
||||||
|
|
||||||
|
if icon_path.is_file() {
|
||||||
|
if let Ok(icon_data) = fs::read(icon_path) {
|
||||||
|
compiled.add_file("pack.png", VFile::Binary(icon_data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let assets_path = args.assets.clone().or(project_config
|
let assets_path = args.assets.clone().or(project_config
|
||||||
.compiler
|
.compiler
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::{env, path::PathBuf};
|
use std::{env, fs, path::PathBuf};
|
||||||
|
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use path_absolutize::Absolutize;
|
use path_absolutize::Absolutize;
|
||||||
use shulkerbox::virtual_fs::VFolder;
|
use shulkerbox::virtual_fs::{VFile, VFolder};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Error,
|
error::Error,
|
||||||
|
@ -40,7 +40,15 @@ pub fn package(_verbose: bool, args: &PackageArgs) -> Result<()> {
|
||||||
.join("src"),
|
.join("src"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let compiled = shulkerscript_lang::compile(&script_paths)?;
|
let mut compiled = shulkerscript_lang::compile(&script_paths)?;
|
||||||
|
|
||||||
|
let icon_path = toml_path.parent().unwrap().join("pack.png");
|
||||||
|
|
||||||
|
if icon_path.is_file() {
|
||||||
|
if let Ok(icon_data) = fs::read(icon_path) {
|
||||||
|
compiled.add_file("pack.png", VFile::Binary(icon_data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let assets_path = args.build_args.assets.clone().or(project_config
|
let assets_path = args.build_args.assets.clone().or(project_config
|
||||||
.compiler
|
.compiler
|
||||||
|
|
Loading…
Reference in New Issue