Exemple #1
0
func (parser *Parser) ParseFile(path string) error {
	ext := filepath.Ext(path)
	filetype := getFileTypeByExtension(ext)

	f, err := ast.NewFile(path)
	if err != nil {
		return err
	}
	data, err := f.ReadFile()
	if err != nil {
		return err
	}

	parser.Content = string(data)
	parser.File = f

	switch filetype {
	case ScssFileType:
		parser.ParseScss(parser.Content)
		break
	default:
		return fmt.Errorf("Unsupported file format: %s", path)
	}
	return nil
}
Exemple #2
0
func (parser *Parser) ReadFile(file string) error {
	f, err := ast.NewFile(file)
	if err != nil {
		return err
	}
	data, err := f.ReadFile()
	if err != nil {
		return err
	}
	parser.File = f
	parser.Content = string(data)
	return nil
}