aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/run_script_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-22 01:29:48 +0900
committernsfisis <nsfisis@gmail.com>2026-05-22 01:43:48 +0900
commit0b06f54103490e3ce5658e82bbc0119633e26cd8 (patch)
tree687b075131d3679725e77e0931ff7c503a6c3034 /crates/shirabe/src/command/run_script_command.rs
parent2914770fba6b3cc03a68fae493f60470a41962ec (diff)
downloadphp-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.gz
php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.zst
php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.zip
refactor(composer): unify Composer/PartialComposer via Rc handles
Model PHP's `Composer extends PartialComposer` as a PartialOrFullComposer enum and merge partial_composer.rs into composer.rs. Introduce ComposerHandle / PartialComposerHandle (plus their Weak variants) so the graph can be shared, and build it at once with Rc::new_cyclic in the factory to resolve the back-reference cycles. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/run_script_command.rs')
-rw-r--r--crates/shirabe/src/command/run_script_command.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs
index 8121feb..436d906 100644
--- a/crates/shirabe/src/command/run_script_command.rs
+++ b/crates/shirabe/src/command/run_script_command.rs
@@ -7,7 +7,6 @@ use shirabe_external_packages::symfony::component::console::output::OutputInterf
use shirabe_php_shim::{InvalidArgumentException, PhpMixed, RuntimeException};
use crate::command::{BaseCommand, BaseCommandData, HasBaseCommandData};
-use crate::composer::Composer;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::io::IOInterface;
@@ -184,6 +183,9 @@ impl RunScriptCommand {
}
let composer = self.require_composer(None, None)?;
+ let dispatcher = crate::command::composer_full(&composer)
+ .get_event_dispatcher()
+ .clone();
let dev_mode = input.get_option("dev").as_bool().unwrap_or(false)
|| !input.get_option("no-dev").as_bool().unwrap_or(false);
// TODO(phase-b): ScriptEvent::new takes Composer/IOInterface by value; placeholder construction.
@@ -224,8 +226,7 @@ impl RunScriptCommand {
Platform::put_env("COMPOSER_DEV_MODE", if dev_mode { "1" } else { "0" });
- Ok(composer
- .get_event_dispatcher()
+ Ok(dispatcher
.borrow_mut()
.dispatch_script(&script, dev_mode, args, IndexMap::new())?)
}
@@ -254,10 +255,11 @@ impl RunScriptCommand {
}
fn get_scripts(&mut self) -> Result<Vec<(String, String)>> {
- let scripts = self
- .require_composer(None, None)?
+ let composer = self.require_composer(None, None)?;
+ let scripts = crate::command::composer_full(&composer)
.get_package()
.get_scripts();
+ drop(composer);
if scripts.is_empty() {
return Ok(vec![]);
}