Page MenuHomePhabricator
Paste P15869

(An Untitled Masterwork)
ActivePublic

Authored by Addshore on May 9 2021, 8:32 PM.
diff --git a/cmd/mwdd_mediawiki.go b/cmd/mwdd_mediawiki.go
index 9f5afa1..a777194 100644
--- a/cmd/mwdd_mediawiki.go
+++ b/cmd/mwdd_mediawiki.go
@@ -301,11 +301,20 @@ var mwddMediawikiComposerCmd = &cobra.Command{
Example: " composer info\n composer install -- --ignore-platform-reqs",
Run: func(cmd *cobra.Command, args []string) {
mwdd.DefaultForUser().EnsureReady()
- mwdd.DefaultForUser().DockerExec(applyRelevantWorkingDirectory(mwdd.DockerExecCommand{
- DockerComposeService: "mediawiki",
- Command: append([]string{"composer"},args...),
- User: User,
- }))
+
+ runArgs := []string{
+ "--rm", "--no-deps",
+ "--entrypoint","composer",
+ "-u", User,
+ "-w", relevantWorkingDirectory(),
+ }
+
+ mwdd.DefaultForUser().Run(
+ "mediawiki",
+ runArgs,
+ args,
+ exec.HandlerOptions{},
+ )
},
}
@@ -394,18 +403,19 @@ var mwddMediawikiExecCmd = &cobra.Command{
}
var applyRelevantWorkingDirectory = func( dockerExecCommand mwdd.DockerExecCommand ) mwdd.DockerExecCommand {
+ dockerExecCommand.WorkingDir = relevantWorkingDirectory()
+ return dockerExecCommand
+}
+
+var relevantWorkingDirectory = func() string {
currentWorkingDirectory, _ := os.Getwd()
mountedMwDirectory := mwdd.DefaultForUser().Env().Get("MEDIAWIKI_VOLUMES_CODE")
- fmt.Println(currentWorkingDirectory)
- fmt.Println(mountedMwDirectory)
- // For paths inside the mediawiki path
if( strings.HasPrefix( currentWorkingDirectory,mountedMwDirectory ) ) {
- dockerExecCommand.WorkingDir = strings.Replace(currentWorkingDirectory, mountedMwDirectory, "/var/www/html/w", 1)
- } else {
- fmt.Println("This command is not supported outside of the MediaWiki core directory: " + mountedMwDirectory)
- os.Exit(1)
+ return strings.Replace(currentWorkingDirectory, mountedMwDirectory, "/var/www/html/w", 1)
}
- return dockerExecCommand
+ fmt.Println("This command is not supported outside of the MediaWiki core directory: " + mountedMwDirectory)
+ os.Exit(1)
+ return ""
}
func init() {
diff --git a/internal/mwdd/root.go b/internal/mwdd/root.go
index 5726477..2a12ad4 100644
--- a/internal/mwdd/root.go
+++ b/internal/mwdd/root.go
@@ -122,6 +122,17 @@ func (m MWDD) Exec( service string, commandAndArgs []string, options exec.Handle
)
}
+/*Run runs `docker-compose run <runArgs> -T <service> <commandAndArgs>`*/
+func (m MWDD) Run( service string, runArgs []string, commandAndArgs []string, options exec.HandlerOptions ) {
+ m.DockerComposeTTY(
+ DockerComposeCommand{
+ Command: "run",
+ CommandArguments: append( runArgs, append( []string{ service }, commandAndArgs... )... ),
+ HandlerOptions: options,
+ },
+ )
+}
+
/*ExecNoOutput runs `docker-compose exec -T <service> <commandAndArgs>` with not output*/
func (m MWDD) ExecNoOutput( service string, commandAndArgs []string, options exec.HandlerOptions ) error {
options.HandleStdout = func(stdout bytes.Buffer) {}