github.com/vugu/vugu@v0.3.6-0.20240430171613-3f6f402e014b/distutil/distutil.go (about)

     1  /*
     2  Package distutil has some useful functions for building your Vugu application's distribution
     3  
     4  Rather than introducing third party build tools.  Authors of Vugu-based applications are
     5  encouraged to build their distribution files (output which is run on the production server)
     6  using a simple .go file which can be "go run"ed.  This package makes some common tasks simpler:
     7  
     8  Copying a directory of static files from one location to another.  The destination directory
     9  can safely be a child of the source directory.  Files which are up to date are not re-copied, for speed.
    10  
    11  	// by default uses DefaultFileInclPattern, matches common static file extensions
    12  	distutil.MustCopyDirFiltered(fromDir, toDir, nil)
    13  
    14  You can also provide your own pattern to say which files to copy:
    15  
    16  	distutil.MustCopyDirFiltered(fromDir, toDir, regexp.MustCompile(`[.](css|js|map|jpg|png|wasm)$`)
    17  
    18  File the wasm_exec.js file included with your Go distribution and copy that:
    19  
    20  	distutil.MustCopyFile(distutil.MustWasmExecJsPath(), filepath.Join(toDir, "wasm_exec.js"))
    21  
    22  Run a command and automatically include $GOPATH/bin (defaults to $HOME/go/bin) to $PATH.
    23  This makes it easy to ensure tools installed by "go get" are available during "go generate".
    24  (The output of the command is returned as a string, panics on error.)
    25  
    26  	fmt.Print(distutil.MustExec("go", "generate", "."))
    27  
    28  Executing a command while overriding certain environment variables is also easy:
    29  
    30  	fmt.Print(distutil.MustEnvExec(
    31  		[]string{"GOOS=js", "GOARCH=wasm"},
    32  		"go", "build", "-o", filepath.Join(outDir, "main.wasm"), "."))
    33  
    34  */
    35  package distutil