-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nodocs and noembeddocs build tags (#431)
Add nodocs and noembeddocs build tags
- Loading branch information
Showing
4 changed files
with
67 additions
and
4 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,19 @@ | ||
// +build !nodocs | ||
// +build !noembeddocs | ||
|
||
package cmd | ||
|
||
import packr "github.com/gobuffalo/packr/v2" | ||
|
||
// DocsDir is unused when chezmoi is built with embedded docs. | ||
var DocsDir = "" | ||
|
||
var docsBox = packr.New("docs", "../docs") | ||
|
||
func getDocsFilenames() ([]string, error) { | ||
return docsBox.List(), nil | ||
} | ||
|
||
func getDoc(filename string) ([]byte, error) { | ||
return docsBox.Find(filename) | ||
} |
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,27 @@ | ||
// +build !nodocs | ||
// +build noembeddocs | ||
|
||
package cmd | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// DocsDir is the directory containing docs when chezmoi is built without | ||
// embedded docs. It should be an absolute path. | ||
var DocsDir = "docs" | ||
|
||
func getDocsFilenames() ([]string, error) { | ||
f, err := os.Open(DocsDir) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer f.Close() | ||
return f.Readdirnames(-1) | ||
} | ||
|
||
func getDoc(filename string) ([]byte, error) { | ||
return ioutil.ReadFile(filepath.Join(DocsDir, filename)) | ||
} |
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