-
-
Notifications
You must be signed in to change notification settings - Fork 580
/
composer.go
45 lines (40 loc) · 1.18 KB
/
composer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cmd
import (
"fmt"
"github.com/drud/ddev/pkg/ddevapp"
"github.com/drud/ddev/pkg/util"
"github.com/spf13/cobra"
"os"
)
var ComposerCmd = &cobra.Command{
Use: "composer [command]",
Short: "Executes a composer command within the web container",
Long: `Executes a composer command at the project root in the web container. Generally,
any composer command can be forwarded to the container context by prepending
the command with 'ddev'.`,
Example: `ddev composer install
ddev composer require <package>
ddev composer outdated --minor-only
ddev composer create drupal/recommended-project`,
Run: func(cmd *cobra.Command, args []string) {
app, err := ddevapp.GetActiveApp("")
if err != nil {
util.Failed(err.Error())
}
if app.SiteStatus() != ddevapp.SiteRunning {
if err = app.Start(); err != nil {
util.Failed("Failed to start %s: %v", app.Name, err)
}
}
stdout, stderr, err := app.Composer(args)
if err != nil {
util.Failed("composer %v failed, %v. stderr=%v", args, err, stderr)
}
_, _ = fmt.Fprint(os.Stderr, stderr)
_, _ = fmt.Fprint(os.Stdout, stdout)
},
}
func init() {
RootCmd.AddCommand(ComposerCmd)
ComposerCmd.Flags().SetInterspersed(false)
}