forked from rojo-rbx/rojo
Simplify plugin installation by using Plugins instead of InstalledPlugins
This commit is contained in:
@@ -27,7 +27,7 @@ pub fn serve(project_dir: &PathBuf, override_port: Option<u64>) {
|
||||
|
||||
println!("Using project {:#?}", project);
|
||||
|
||||
roblox_studio::install_bundled_plugin();
|
||||
roblox_studio::install_bundled_plugin().unwrap();
|
||||
|
||||
let mut session = Session::new(project.clone());
|
||||
session.start();
|
||||
|
||||
@@ -10,10 +10,7 @@ use std::env;
|
||||
compile_error!("`bundle-plugin` feature must be set for release builds.");
|
||||
|
||||
#[cfg(feature = "bundle-plugin")]
|
||||
static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxm");
|
||||
|
||||
const ROJO_HOTSWAP_PLUGIN_ID: &'static str = "0";
|
||||
const ROJO_RELEASE_PLUGIN_ID: &'static str = "1997686364";
|
||||
static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxmx");
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn get_install_location() -> Option<PathBuf> {
|
||||
@@ -36,43 +33,30 @@ pub fn get_install_location() -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "bundle-plugin")]
|
||||
pub fn get_plugin_location() -> Option<PathBuf> {
|
||||
let mut location = get_install_location()?;
|
||||
|
||||
location.push("InstalledPlugins");
|
||||
location.push(ROJO_RELEASE_PLUGIN_ID);
|
||||
|
||||
Some(location)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "bundle-plugin"))]
|
||||
pub fn get_plugin_location() -> Option<PathBuf> {
|
||||
let mut location = get_install_location()?;
|
||||
|
||||
location.push("InstalledPlugins");
|
||||
location.push(ROJO_HOTSWAP_PLUGIN_ID);
|
||||
location.push("Plugins/Rojo.rbxmx");
|
||||
|
||||
Some(location)
|
||||
}
|
||||
|
||||
#[cfg(feature = "bundle-plugin")]
|
||||
pub fn install_bundled_plugin() -> Option<()> {
|
||||
use std::fs::create_dir_all;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
println!("Installing plugin...");
|
||||
|
||||
// TODO: Check error of this value; the only one we actually want to ignore
|
||||
// is ErrorKind::AlreadyExists probably.
|
||||
let _ = create_dir_all(get_plugin_location()?);
|
||||
|
||||
// TODO: Copy PLUGIN_RBXM to plugin_location/Plugin.rbxm
|
||||
// TODO: Update PluginMetadata.json
|
||||
let mut file = File::create(get_plugin_location()?).ok()?;
|
||||
file.write_all(PLUGIN_RBXM).ok()?;
|
||||
|
||||
Some(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "bundle-plugin"))]
|
||||
pub fn install_bundled_plugin() {
|
||||
pub fn install_bundled_plugin() -> Option<()> {
|
||||
println!("Skipping plugin installation, bundle-plugin not set.");
|
||||
|
||||
Some(())
|
||||
}
|
||||
Reference in New Issue
Block a user