本文整理汇总了Golang中github.com/getgauge/common.FileExists函数的典型用法代码示例。如果您正苦于以下问题:Golang FileExists函数的具体用法?Golang FileExists怎么用?Golang FileExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FileExists函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: createOrAppendToGemFile
func createOrAppendToGemFile() {
destFile := path.Join(projectRoot, gem_file)
srcFile := path.Join(skelDir, gem_file)
showMessage("create", destFile)
if !common.FileExists(destFile) {
err := common.CopyFile(srcFile, destFile)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to copy %s. %s", srcFile, err.Error()))
}
}
showMessage("append", destFile)
f, err := os.OpenFile(destFile, os.O_APPEND|os.O_WRONLY, 0666)
if err != nil {
panic(err)
}
defer f.Close()
version, err := common.GetGaugePluginVersion("ruby")
if err != nil {
panic(err)
}
if _, err = f.WriteString(fmt.Sprintf("gem 'gauge-ruby', '~>%s', :group => [:development, :test]\n", version)); err != nil {
panic(err)
}
}
开发者ID:cbusbey,项目名称:gauge-ruby,代码行数:27,代码来源:gauge-ruby.go
示例2: createJavaPropertiesFile
func createJavaPropertiesFile() {
destFile := filepath.Join(envDir, "default", "java.properties")
showMessage("create", destFile)
if common.FileExists(destFile) {
showMessage("skip", destFile)
} else {
srcFile := filepath.Join(pluginDir, skelDir, envDir, "java.properties")
if !common.FileExists(srcFile) {
showMessage("error", fmt.Sprintf("java.properties does not exist at %s. \n", srcFile))
return
}
err := common.CopyFile(srcFile, destFile)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to copy %s. %s \n", srcFile, err.Error()))
}
}
}
开发者ID:haroon-sheikh,项目名称:gauge-java,代码行数:17,代码来源:gauge-java.go
示例3: createStepImplementationClass
func createStepImplementationClass() {
javaSrc := filepath.Join(defaultSrcDir, "test", java)
destFile := filepath.Join(javaSrc, step_implementation_class)
showMessage("create", destFile)
if common.FileExists(destFile) {
showMessage("skip", destFile)
} else {
srcFile := filepath.Join(pluginDir, skelDir, step_implementation_class)
if !common.FileExists(srcFile) {
showMessage("error", fmt.Sprintf("%s Does not exist.\n", step_implementation_class))
return
}
err := common.CopyFile(srcFile, destFile)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to copy %s. %s \n", srcFile, err.Error()))
}
}
}
开发者ID:haroon-sheikh,项目名称:gauge-java,代码行数:18,代码来源:gauge-java.go
示例4: GetSpecFiles
func GetSpecFiles(specSource string) []string {
specFiles := make([]string, 0)
if common.DirExists(specSource) {
specFiles = append(specFiles, FindSpecFilesIn(specSource)...)
} else if common.FileExists(specSource) && IsValidSpecExtension(specSource) {
specFile, _ := filepath.Abs(specSource)
specFiles = append(specFiles, specFile)
}
return specFiles
}
开发者ID:ranjeet-floyd,项目名称:gauge,代码行数:10,代码来源:finder.go
示例5: GetSpecFiles
// GetSpecFiles returns the list of spec files present at the given path.
// If the path itself represents a spec file, it returns the same.
func GetSpecFiles(path string) []string {
var specFiles []string
if common.DirExists(path) {
specFiles = append(specFiles, FindSpecFilesIn(path)...)
} else if common.FileExists(path) && IsValidSpecExtension(path) {
f, _ := filepath.Abs(path)
specFiles = append(specFiles, f)
}
return specFiles
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:12,代码来源:fileUtils.go
示例6: GetLanguageJSONFilePath
func GetLanguageJSONFilePath(language string) (string, error) {
languageInstallDir, err := GetInstallDir(language, "")
if err != nil {
return "", err
}
languageJSON := filepath.Join(languageInstallDir, fmt.Sprintf("%s.json", language))
if !common.FileExists(languageJSON) {
return "", fmt.Errorf("Failed to find the implementation for: %s. %s does not exist.", language, languageJSON)
}
return languageJSON, nil
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:12,代码来源:plugin.go
示例7: installPluginFromZip
func installPluginFromZip(zipFile string, language string) error {
unzippedPluginDir, err := common.UnzipArchive(zipFile)
if err != nil {
return fmt.Errorf("Failed to unzip plugin-zip file %s.", err.Error())
}
logger.Info("Plugin unzipped to => %s\n", unzippedPluginDir)
hasPluginJSON := common.FileExists(filepath.Join(unzippedPluginDir, pluginJSON))
if hasPluginJSON {
return installPluginFromDir(unzippedPluginDir)
}
return installRunnerFromDir(unzippedPluginDir, language)
}
开发者ID:andrewmkrug,项目名称:gauge,代码行数:13,代码来源:install.go
示例8: createStepImplementationFile
func createStepImplementationFile() {
destFile := path.Join(projectRoot, step_implementations_dir, step_implementation_file)
showMessage("create", destFile)
if common.FileExists(destFile) {
showMessage("skip", destFile)
} else {
srcFile := path.Join(skelDir, step_implementation_file)
err := common.CopyFile(srcFile, destFile)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to copy %s. %s", srcFile, err.Error()))
}
}
}
开发者ID:cbusbey,项目名称:gauge-ruby,代码行数:13,代码来源:gauge-ruby.go
示例9: createRubyPropertiesFile
func createRubyPropertiesFile() {
destFile := path.Join(projectRoot, envDir, "default", ruby_properties_file)
showMessage("create", destFile)
if common.FileExists(destFile) {
showMessage("skip", destFile)
} else {
srcFile := path.Join(skelDir, envDir, ruby_properties_file)
err := common.CopyFile(srcFile, destFile)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to copy %s. %s", srcFile, err.Error()))
}
}
}
开发者ID:cbusbey,项目名称:gauge-ruby,代码行数:13,代码来源:gauge-ruby.go
示例10: installPluginFromZip
func installPluginFromZip(zipFile string, language string) error {
unzippedPluginDir, err := common.UnzipArchive(zipFile)
if err != nil {
return errors.New(fmt.Sprintf("Failed to unzip plugin-zip file %s.", err))
}
logger.Log.Info("Plugin unzipped to => %s\n", unzippedPluginDir)
hasPluginJson := common.FileExists(filepath.Join(unzippedPluginDir, pluginJson))
if hasPluginJson {
return installPluginFromDir(unzippedPluginDir)
} else {
return installRunnerFromDir(unzippedPluginDir, language)
}
}
开发者ID:krwhitney,项目名称:gauge,代码行数:14,代码来源:install.go
示例11: parsePluginJSON
func parsePluginJSON(pluginDir, pluginName string) (*GaugePlugin, error) {
var file string
if common.FileExists(filepath.Join(pluginDir, pluginName+jsonExt)) {
file = filepath.Join(pluginDir, pluginName+jsonExt)
} else {
file = filepath.Join(pluginDir, pluginJSON)
}
var gp GaugePlugin
contents, err := common.ReadFileContents(file)
if err != nil {
return nil, err
}
if err = json.Unmarshal([]byte(contents), &gp); err != nil {
return nil, err
}
return &gp, nil
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:18,代码来源:install.go
示例12: IsPluginInstalled
func IsPluginInstalled(pluginName, pluginVersion string) bool {
pluginsInstallDir, err := common.GetPluginsInstallDir(pluginName)
if err != nil {
return false
}
thisPluginDir := filepath.Join(pluginsInstallDir, pluginName)
if !common.DirExists(thisPluginDir) {
return false
}
if pluginVersion != "" {
pluginJSON := filepath.Join(thisPluginDir, pluginVersion, common.PluginJSONFile)
if common.FileExists(pluginJSON) {
return true
}
return false
}
return true
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:20,代码来源:plugin.go
示例13: InstallPluginZip
func InstallPluginZip(zipFile string, pluginName string) {
tempDir := common.GetTempDir()
unzippedPluginDir, err := common.UnzipArchive(zipFile, tempDir)
defer common.Remove(tempDir)
if err != nil {
common.Remove(tempDir)
logger.Fatalf("Failed to install plugin. %s\n", err.Error())
}
logger.Info("Plugin unzipped to => %s\n", unzippedPluginDir)
hasPluginJSON := common.FileExists(filepath.Join(unzippedPluginDir, pluginJSON))
if hasPluginJSON {
err = installPluginFromDir(unzippedPluginDir)
} else {
err = installRunnerFromDir(unzippedPluginDir, pluginName)
}
if err != nil {
common.Remove(tempDir)
logger.Fatalf("Failed to install plugin. %s\n", err.Error())
}
logger.Info("Successfully installed plugin from file.")
}
开发者ID:0-T-0,项目名称:gauge,代码行数:22,代码来源:install.go
示例14: addDefaultPropertiesToProject
func addDefaultPropertiesToProject() {
defaultPropertiesFile := getDefaultPropertiesFile()
reportsDirProperty := &(common.Property{
Comment: "The path to the gauge reports directory. Should be either relative to the project directory or an absolute path",
Name: gaugeReportsDirEnvName,
DefaultValue: defaultReportsDir})
overwriteReportProperty := &(common.Property{
Comment: "Set as false if gauge reports should not be overwritten on each execution. A new time-stamped directory will be created on each execution.",
Name: overwriteReportsEnvProperty,
DefaultValue: "true"})
if !common.FileExists(defaultPropertiesFile) {
fmt.Printf("Failed to setup html report plugin in project. Default properties file does not exist at %s. \n", defaultPropertiesFile)
return
}
if err := common.AppendProperties(defaultPropertiesFile, reportsDirProperty, overwriteReportProperty); err != nil {
fmt.Printf("Failed to setup html report plugin in project: %s \n", err)
return
}
fmt.Println("Succesfully added configurations for html-report to env/default/default.properties")
}
开发者ID:jean,项目名称:html-report,代码行数:23,代码来源:htmlReport.go
示例15: TestDownloadSuccess
func (s *MySuite) TestDownloadSuccess(c *C) {
os.Mkdir("temp", 0755)
defer os.RemoveAll("temp")
handler := func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "All OK", http.StatusOK)
}
server := httptest.NewServer(http.HandlerFunc(handler))
defer server.Close()
actualDownloadedFilePath, err := Download(server.URL, "temp", "", false)
expectedDownloadFilePath := filepath.Join("temp", strings.TrimPrefix(server.URL, "http://"))
absoluteDownloadFilePath, _ := filepath.Abs(expectedDownloadFilePath)
expectedFileContents := "All OK\n"
c.Assert(err, Equals, nil)
c.Assert(actualDownloadedFilePath, Equals, expectedDownloadFilePath)
c.Assert(common.FileExists(absoluteDownloadFilePath), Equals, true)
actualFileContents, err := common.ReadFileContents(absoluteDownloadFilePath)
c.Assert(err, Equals, nil)
c.Assert(actualFileContents, Equals, expectedFileContents)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:24,代码来源:httpUtils_test.go
示例16: createProjectTemplate
func createProjectTemplate(language string) error {
if !install.IsCompatibleLanguagePluginInstalled(language) {
logger.Info("Compatible %s plugin is not installed \n", language)
logger.Info("Installing plugin => %s ... \n\n", language)
if result := install.InstallPlugin(language, ""); !result.Success {
return fmt.Errorf("Failed to install plugin %s . %s \n", language, result.Error.Error())
}
}
// Create the project manifest
showMessage("create", common.ManifestFile)
if common.FileExists(common.ManifestFile) {
showMessage("skip", common.ManifestFile)
}
manifest := &manifest.Manifest{Language: language, Plugins: defaultPlugins}
if err := manifest.Save(); err != nil {
return err
}
// creating the spec directory
showMessage("create", specsDirName)
if !common.DirExists(specsDirName) {
err := os.Mkdir(specsDirName, common.NewDirectoryPermissions)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", specsDirName, err.Error()))
}
} else {
showMessage("skip", specsDirName)
}
// Copying the skeleton file
skelFile, err := common.GetSkeletonFilePath(skelFileName)
if err != nil {
return err
}
specFile := path.Join(specsDirName, skelFileName)
showMessage("create", specFile)
if common.FileExists(specFile) {
showMessage("skip", specFile)
} else {
err = common.CopyFile(skelFile, specFile)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", specFile, err.Error()))
}
}
// Creating the env directory
showMessage("create", common.EnvDirectoryName)
if !common.DirExists(common.EnvDirectoryName) {
err = os.Mkdir(common.EnvDirectoryName, common.NewDirectoryPermissions)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", common.EnvDirectoryName, err.Error()))
}
}
defaultEnv := path.Join(common.EnvDirectoryName, envDefaultDirName)
showMessage("create", defaultEnv)
if !common.DirExists(defaultEnv) {
err = os.Mkdir(defaultEnv, common.NewDirectoryPermissions)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", defaultEnv, err.Error()))
}
}
defaultJSON, err := common.GetSkeletonFilePath(path.Join(common.EnvDirectoryName, common.DefaultEnvFileName))
if err != nil {
return err
}
defaultJSONDest := path.Join(defaultEnv, common.DefaultEnvFileName)
showMessage("create", defaultJSONDest)
err = common.CopyFile(defaultJSON, defaultJSONDest)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", defaultJSONDest, err.Error()))
}
return runner.ExecuteInitHookForRunner(language)
}
开发者ID:andrewmkrug,项目名称:gauge,代码行数:75,代码来源:init.go
示例17: createProjectTemplate
func createProjectTemplate(language string) error {
// Create the project manifest
showMessage("create", common.ManifestFile)
if common.FileExists(common.ManifestFile) {
showMessage("skip", common.ManifestFile)
}
manifest := &manifest.Manifest{Language: language, Plugins: defaultPlugins}
if err := manifest.Save(); err != nil {
return err
}
// creating the spec directory
showMessage("create", specsDirName)
if !common.DirExists(specsDirName) {
err := os.Mkdir(specsDirName, common.NewDirectoryPermissions)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", specsDirName, err.Error()))
}
} else {
showMessage("skip", specsDirName)
}
// Copying the skeleton file
skelFile, err := common.GetSkeletonFilePath(skelFileName)
if err != nil {
return err
}
specFile := path.Join(specsDirName, skelFileName)
showMessage("create", specFile)
if common.FileExists(specFile) {
showMessage("skip", specFile)
} else {
err = common.CopyFile(skelFile, specFile)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", specFile, err.Error()))
}
}
// Creating the env directory
showMessage("create", common.EnvDirectoryName)
if !common.DirExists(common.EnvDirectoryName) {
err = os.Mkdir(common.EnvDirectoryName, common.NewDirectoryPermissions)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", common.EnvDirectoryName, err.Error()))
}
}
defaultEnv := path.Join(common.EnvDirectoryName, envDefaultDirName)
showMessage("create", defaultEnv)
if !common.DirExists(defaultEnv) {
err = os.Mkdir(defaultEnv, common.NewDirectoryPermissions)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", defaultEnv, err.Error()))
}
}
defaultJSON, err := common.GetSkeletonFilePath(path.Join(common.EnvDirectoryName, common.DefaultEnvFileName))
if err != nil {
return err
}
defaultJSONDest := path.Join(defaultEnv, common.DefaultEnvFileName)
showMessage("create", defaultJSONDest)
err = common.CopyFile(defaultJSON, defaultJSONDest)
if err != nil {
showMessage("error", fmt.Sprintf("Failed to create %s. %s", defaultJSONDest, err.Error()))
}
return runner.ExecuteInitHookForRunner(language)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:67,代码来源:init.go
注:本文中的github.com/getgauge/common.FileExists函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论