github.com/LGUG2Z/story@v0.4.1/manifest/ignore.go (about)

     1  package manifest
     2  
     3  import (
     4  	"bufio"
     5  	"fmt"
     6  	"os"
     7  )
     8  
     9  func LoadStoryIgnore(basePath string) (map[string]bool, error) {
    10  	storyIgnoreFilePath := fmt.Sprintf("%s/.storyignore", basePath)
    11  	storyIgnore := make(map[string]bool)
    12  
    13  	if _, err := os.Stat(storyIgnoreFilePath); os.IsNotExist(err) {
    14  		return storyIgnore, nil
    15  	}
    16  
    17  	file, err := os.Open(storyIgnoreFilePath)
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  	defer file.Close()
    22  
    23  	scanner := bufio.NewScanner(file)
    24  	for scanner.Scan() {
    25  		storyIgnore[scanner.Text()] = true
    26  	}
    27  
    28  	if err := scanner.Err(); err != nil {
    29  		return nil, err
    30  	}
    31  
    32  	return storyIgnore, nil
    33  }