func()

in plugin/step/install/darwin/pkg/pkg.go [183:211]


func (s *Step) mountDMG(dmg string) error {
	ctx := context.Background()

	tmpdir, err := temp.Dir("", "")
	if err != nil {
		return err
	}

	cmd := exec.CommandContext(ctx,
		"hdiutil", "mount", dmg,
		"-mountroot", tmpdir,
	)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	if err := cmd.Run(); err != nil {
		return err
	}

	dir, err := getDMGVolume(tmpdir)
	if err != nil {
		s.downloadPath = tmpdir
		defer func() { _ = s.unmountDMG() }()
		return err
	}

	s.downloadPath = dir
	return nil
}