-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package build | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
// AssetsCopy does a direct copy of any static assets. | ||
func AssetsCopy(buildPath string) { | ||
|
||
defer Benchmark(time.Now(), "Copying static assets into build dir") | ||
|
||
Log("\nCopying static assets:") | ||
|
||
copiedSourceCounter := 0 | ||
|
||
assetFilesErr := filepath.Walk("assets", func(assetPath string, assetFileInfo os.FileInfo, err error) error { | ||
destPath := buildPath + "/" + assetPath | ||
if assetFileInfo.IsDir() { | ||
// Make directory if it doesn't exist. | ||
os.MkdirAll(destPath, os.ModePerm) | ||
} | ||
from, err := os.Open(assetPath) | ||
if err != nil { | ||
fmt.Printf("Could not open asset for copying: %s\n", err) | ||
} | ||
defer from.Close() | ||
|
||
to, err := os.Create(destPath) | ||
if err != nil { | ||
fmt.Printf("Could not create destination asset for copying: %s\n", err) | ||
} | ||
defer to.Close() | ||
|
||
_, fileCopyErr := io.Copy(to, from) | ||
if err != nil { | ||
fmt.Printf("Could not copy asset from source to destination: %s\n", fileCopyErr) | ||
} | ||
|
||
copiedSourceCounter++ | ||
return nil | ||
}) | ||
if assetFilesErr != nil { | ||
fmt.Printf("Could not get asset file: %s", assetFilesErr) | ||
} | ||
|
||
Log("Number of assets copied: " + strconv.Itoa(copiedSourceCounter)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters