Skip to content
New issue

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

flag for ignoring file mode / permissions #95

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions statik.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (
flagSrc = flag.String("src", path.Join(".", "public"), "")
flagDest = flag.String("dest", ".", "")
flagNoMtime = flag.Bool("m", false, "")
flagNoMode = flag.Bool("P", false, "")
flagNoCompress = flag.Bool("Z", false, "")
flagForce = flag.Bool("f", false, "")
flagTags = flag.String("tags", "", "")
Expand All @@ -56,6 +57,7 @@ Options:
-f Override destination if it already exists, false by default.
-include Wildcard to filter files to include, "*.*" by default.
-m Ignore modification times on files, false by default.
-P Ignore file mode/permissions, false by default.
-Z Do not use compression, false by default.

-p Name of the generated package, "statik" by default.
Expand Down Expand Up @@ -232,6 +234,11 @@ func generateSource(srcPath string, includes string) (file *os.File, err error)
// Do NOT use fHeader.Modified as it only works on go >= 1.10
fHeader.SetModTime(mtimeDate)
}
if *flagNoMode {
// Always use the same mode so that the output is deterministic with
// respect to file contents.
fHeader.SetMode(os.ModePerm)
}
fHeader.Name = filepath.ToSlash(relPath)
if !*flagNoCompress {
fHeader.Method = zip.Deflate
Expand Down