<commit_before>package skel

import (
	"io/ioutil"
	"os"
	"path/filepath"

	"github.com/getgauge/common"
	"github.com/getgauge/gauge/logger"
)

func CreateSkelFilesIfRequired() {
	p, err := common.GetConfigurationDir()
	if err != nil {
		logger.GaugeLog.Info("Unable to get path to config. Error: %s", err.Error())
		return
	}
	if _, err := os.Stat(p); os.IsNotExist(err) {
		logger.GaugeLog.Info("Config directory does not exist. Setting up config directory `%s`.", p)
		err = os.MkdirAll(p, common.NewDirectoryPermissions)
		if err != nil {
			logger.GaugeLog.Error("Unable to create config path dir `%s`. Error: %s", p, err.Error())
			return
		}
	}
	WriteFile(filepath.Join(p, "gauge.properties"), gaugeProperties)
	WriteFile(filepath.Join(p, "notice.md"), notice)
	WriteFile(filepath.Join(p, "skel", "specs", "example.spec"), exampleSpec)
	WriteFile(filepath.Join(p, "skel", "env", "default.properties"), defaultProperties)
}

func WriteFile(path, text string) {
	dirPath := filepath.Dir(path)
	if _, err := os.Stat(path); os.IsNotExist(err) {
		err = os.MkdirAll(dirPath, common.NewDirectoryPermissions)
		if err != nil {
			logger.GaugeLog.Error("Unable to create dir `%s`. Error: %s", dirPath, err.Error())
			return
		}
	}
	if _, err := os.Stat(path); os.IsNotExist(err) {
		err := ioutil.WriteFile(path, []byte(text), common.NewFilePermissions)
		if err != nil {
			logger.GaugeLog.Error("Unable to create file `%s`. Error: %s", path, err.Error())
		}
	}
}<commit_msg>write example.spec to skel folder when generating<commit_after>package skel

import (
	"io/ioutil"
	"os"
	"path/filepath"

	"github.com/getgauge/common"
	"github.com/getgauge/gauge/logger"
)

func CreateSkelFilesIfRequired() {
	p, err := common.GetConfigurationDir()
	if err != nil {
		logger.GaugeLog.Info("Unable to get path to config. Error: %s", err.Error())
		return
	}
	if _, err := os.Stat(p); os.IsNotExist(err) {
		logger.GaugeLog.Info("Config directory does not exist. Setting up config directory `%s`.", p)
		err = os.MkdirAll(p, common.NewDirectoryPermissions)
		if err != nil {
			logger.GaugeLog.Error("Unable to create config path dir `%s`. Error: %s", p, err.Error())
			return
		}
	}
	WriteFile(filepath.Join(p, "gauge.properties"), gaugeProperties)
	WriteFile(filepath.Join(p, "notice.md"), notice)
	WriteFile(filepath.Join(p, "skel", "example.spec"), exampleSpec)
	WriteFile(filepath.Join(p, "skel", "env", "default.properties"), defaultProperties)
}

func WriteFile(path, text string) {
	dirPath := filepath.Dir(path)
	if _, err := os.Stat(path); os.IsNotExist(err) {
		err = os.MkdirAll(dirPath, common.NewDirectoryPermissions)
		if err != nil {
			logger.GaugeLog.Error("Unable to create dir `%s`. Error: %s", dirPath, err.Error())
			return
		}
	}
	if _, err := os.Stat(path); os.IsNotExist(err) {
		err := ioutil.WriteFile(path, []byte(text), common.NewFilePermissions)
		if err != nil {
			logger.GaugeLog.Error("Unable to create file `%s`. Error: %s", path, err.Error())
		}
	}
}
{'fraction_non_alphanumeric': 0.16560509554140126, 'fraction_numerical': 0.0, 'mean_word_length': 4.495395948434623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '854909', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1090, 'n_words': 247}