We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When we try to build a project it's not build the project as files are not copied from the .hidden directory to the workspace directory.
.hidden
workspace
There are cp command is used for copy project files in utils/copyDir.go file but it's not working on the Windows platform.
cp
utils/copyDir.go
https://github.com/AuditDeploy/Builder/blob/main/utils/copyDir.go#L17
Suggestion:
We can use https://github.com/otiai10/copy which provides functionality to copy files recursively independent of the platform.
Or We can use the below function which works fine on my Windows machine but not sure about other platforms. We have to test code on other platforms.
func CopyDirectory(scrDir, dest string) error { entries, err := ioutil.ReadDir(scrDir) if err != nil { return err } for _, entry := range entries { sourcePath := filepath.Join(scrDir, entry.Name()) destPath := filepath.Join(dest, entry.Name()) fileInfo, err := os.Stat(sourcePath) if err != nil { return err } // stat, ok := fileInfo.Sys().(*sys.Stat_t) // if !ok { // return fmt.Errorf("failed to get raw syscall.Stat_t data for '%s'", sourcePath) // } switch fileInfo.Mode() & os.ModeType { case os.ModeDir: if err := CreateIfNotExists(destPath, 0755); err != nil { return err } if err := CopyDirectory(sourcePath, destPath); err != nil { return err } case os.ModeSymlink: if err := CopySymLink(sourcePath, destPath); err != nil { return err } default: if err := Copy(sourcePath, destPath); err != nil { return err } } // if err := os.Lchown(destPath, int(stat.Uid), int(stat.Gid)); err != nil { // return err // } isSymlink := entry.Mode()&os.ModeSymlink != 0 if !isSymlink { if err := os.Chmod(destPath, entry.Mode()); err != nil { return err } } } return nil } func Copy(srcFile, dstFile string) error { out, err := os.Create(dstFile) if err != nil { return err } defer out.Close() in, err := os.Open(srcFile) if err != nil { return err } defer in.Close() _, err = io.Copy(out, in) if err != nil { return err } return nil } func Exists(filePath string) bool { if _, err := os.Stat(filePath); os.IsNotExist(err) { return false } return true } func CreateIfNotExists(dir string, perm os.FileMode) error { if Exists(dir) { return nil } if err := os.MkdirAll(dir, perm); err != nil { return fmt.Errorf("failed to create directory: '%s', error: '%s'", dir, err.Error()) } return nil } func CopySymLink(source, dest string) error { link, err := os.Readlink(source) if err != nil { return err } return os.Symlink(link, dest) }
And do the below changes in the copyDir() function.
copyDir()
func CopyDir() { //copies contents of .hidden to workspace hiddenDir := os.Getenv("BUILDER_HIDDEN_DIR") workspaceDir := os.Getenv("BUILDER_WORKSPACE_DIR") err := CopyDirectory(hiddenDir, workspaceDir) if err != nil { log.Println("Error in copy hidden directory.") log.Println(err) } }
Thanks
The text was updated successfully, but these errors were encountered:
@jakestreet Can you follow this issue with the PR branch you created
Sorry, something went wrong.
No branches or pull requests
When we try to build a project it's not build the project as files are not copied from the
.hidden
directory to theworkspace
directory.There are
cp
command is used for copy project files inutils/copyDir.go
file but it's not working on the Windows platform.https://github.com/AuditDeploy/Builder/blob/main/utils/copyDir.go#L17
Suggestion:
We can use https://github.com/otiai10/copy which provides functionality to copy files recursively independent of the platform.
Or We can use the below function which works fine on my Windows machine but not sure about other platforms. We have to test code on other platforms.
And do the below changes in the
copyDir()
function.Thanks
The text was updated successfully, but these errors were encountered: