Skip to content
Snippets Groups Projects
Select Git revision
  • 9e3825e98ce0e28afdf8b0c4f74f4cb84c634c30
  • main default protected
  • trading_hours
  • refactor_trading_hours
  • audit_cleaning_cater_for_non_struct_fields
  • remove-info-logs
  • sl-refactor
  • 18-use-scan-for-param-values
  • 17-order-search-results
  • 4-simplify-framework-2
  • 1-http-error
  • v1.297.0
  • v1.296.0
  • v1.295.0
  • v1.294.0
  • v1.293.0
  • v1.292.0
  • v1.291.0
  • v1.290.0
  • v1.289.0
  • v1.288.0
  • v1.287.0
  • v1.286.0
  • v1.285.0
  • v1.284.0
  • v1.283.0
  • v1.282.0
  • v1.281.0
  • v1.280.0
  • v1.279.0
  • v1.278.0
31 results

api_responses.go

Blame
  • build.go 3.61 KiB
    package mage_helpers
    
    import (
    	"fmt"
    	"os"
    	"os/exec"
    	"path"
    	"runtime"
    	"strings"
    
    	"github.com/magefile/mage/sh"
    )
    
    func Clean(path string) error {
    
    	cmd := exec.Command("rm", "-rf", "build")
    	cmd.Stdout = os.Stdout
    	cmd.Stderr = os.Stderr
    	cmd.Dir = path
    	err := cmd.Run()
    	if err != nil {
    		return err
    	}
    
    	cmd = exec.Command("mkdir", "-p", "build")
    	cmd.Stdout = os.Stdout
    	cmd.Stderr = os.Stderr
    	cmd.Dir = path
    	err = cmd.Run()
    	if err != nil {
    		return err
    	}
    	return nil
    }
    
    func Build(dir string, module string, isDebug bool) error {
    	currentDir, _ := os.Getwd()
    	fullPath := currentDir + "/core/" + dir
    
    	if err := Clean(fullPath); err != nil {
    		return err
    	}
    
    	handler := path.Base(fullPath)
    	fmt.Println(fmt.Sprintf("Building %v", handler))
    
    	outputFileName := handler
    	env := CurrentEnv()
    	fmt.Println("ENV:", env)
    	if env == "playground" {
    		fmt.Println("Using 'bootstrap' for output file name")
    		outputFileName = "bootstrap"
    	}
    
    	outputDir := fmt.Sprintf(currentDir+`/core/build/handlers/%v`, handler)
    	outputFile := fmt.Sprintf(`%v/%v`, outputDir, outputFileName)
    	appPath := fmt.Sprintf(`%v/core/%v`, module, handler)
    	err := BuildGolangApp(outputFile, appPath, module, isDebug)
    	if err != nil {
    		return err
    	}
    
    	// Copy files in handler folder
    	err = copyFilesToBuildDir(fullPath, outputDir)
    	if err != nil {
    		return err
    	}
    
    	// Copy shared files
    	sharedDir := currentDir + "/core/utils"