本文整理汇总了Golang中github.com/bitrise-io/go-utils/pathutil.IsPathExists函数的典型用法代码示例。如果您正苦于以下问题:Golang IsPathExists函数的具体用法?Golang IsPathExists怎么用?Golang IsPathExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsPathExists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDownloadPluginBin
func TestDownloadPluginBin(t *testing.T) {
t.Log("example plugin bin - ")
{
pluginBinURL := analyticsPluginBinURL
destinationDir, err := pathutil.NormalizedOSTempDirPath("TestDownloadPluginBin")
require.NoError(t, err)
exist, err := pathutil.IsPathExists(destinationDir)
require.NoError(t, err)
if exist {
err := os.RemoveAll(destinationDir)
require.NoError(t, err)
}
require.NoError(t, os.MkdirAll(destinationDir, 0777))
destinationPth := filepath.Join(destinationDir, "example")
require.NoError(t, downloadPluginBin(pluginBinURL, destinationPth))
exist, err = pathutil.IsPathExists(destinationPth)
require.NoError(t, err)
require.Equal(t, true, exist)
}
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:25,代码来源:install_test.go
示例2: validate
func (configs ConfigsModel) validate() (string, error) {
// required
if configs.GradleFile == "" {
return "", errors.New("No GradleFile parameter specified!")
}
if exist, err := pathutil.IsPathExists(configs.GradleFile); err != nil {
return "", fmt.Errorf("Failed to check if GradleFile exist at: %s, error: %s", configs.GradleFile, err)
} else if !exist {
return "", fmt.Errorf("GradleFile not exist at: %s", configs.GradleFile)
}
if configs.GradleTasks == "" {
return "", errors.New("No GradleTask parameter specified!")
}
if configs.GradlewPath == "" {
explanation := `
Using a Gradle Wrapper (gradlew) is required, as the wrapper is what makes sure
that the right Gradle version is installed and used for the build.
You can find more information about the Gradle Wrapper (gradlew),
and about how you can generate one (if you would not have one already
in the official guide at: https://docs.gradle.org/current/userguide/gradle_wrapper.html`
return explanation, errors.New("No GradlewPath parameter specified!")
}
if exist, err := pathutil.IsPathExists(configs.GradlewPath); err != nil {
return "", fmt.Errorf("Failed to check if GradlewPath exist at: %s, error: %s", configs.GradlewPath, err)
} else if !exist {
return "", fmt.Errorf("GradlewPath not exist at: %s", configs.GradlewPath)
}
return "", nil
}
开发者ID:bitrise-io,项目名称:steps-gradle-runner,代码行数:34,代码来源:main.go
示例3: initBitriseWorkPaths
func initBitriseWorkPaths() error {
bitriseWorkDirPath, err := pathutil.NormalizedOSTempDirPath("bitrise")
if err != nil {
return err
}
if exist, err := pathutil.IsPathExists(bitriseWorkDirPath); err != nil {
return err
} else if !exist {
if err := os.MkdirAll(bitriseWorkDirPath, 0777); err != nil {
return err
}
}
BitriseWorkDirPath = bitriseWorkDirPath
bitriseWorkStepsDirPath, err := filepath.Abs(filepath.Join(BitriseWorkDirPath, "step_src"))
if err != nil {
return err
}
if exist, err := pathutil.IsPathExists(bitriseWorkStepsDirPath); err != nil {
return err
} else if !exist {
if err := os.MkdirAll(bitriseWorkStepsDirPath, 0777); err != nil {
return err
}
}
BitriseWorkStepsDirPath = bitriseWorkStepsDirPath
return nil
}
开发者ID:viktorbenei,项目名称:bitrise,代码行数:29,代码来源:paths.go
示例4: isCacheAvailable
func isCacheAvailable(srcDir string) (bool, error) {
carthageDir := filepath.Join(srcDir, carthageDirName)
if exist, err := pathutil.IsPathExists(carthageDir); err != nil {
return false, err
} else if !exist {
return false, nil
}
buildDir := filepath.Join(carthageDir, buildDirName)
if exist, err := pathutil.IsPathExists(buildDir); err != nil {
return false, err
} else if exist {
pattern := filepath.Join(buildDir, "*")
files, err := filepath.Glob(pattern)
if err != nil {
return false, err
}
if len(files) == 0 {
return false, nil
}
} else {
return false, nil
}
// read cahce
cacheContent := ""
cacheFilePth := filepath.Join(srcDir, carthageDirName, cacheFileName)
if exist, err := pathutil.IsPathExists(cacheFilePth); err != nil {
return false, err
} else if exist {
cacheContent, err = fileutil.ReadStringFromFile(cacheFilePth)
if err != nil {
return false, err
}
} else {
return false, nil
}
swiftVersion, err := swiftVersion()
if err != nil {
return false, err
}
resolvedFilePath := filepath.Join(srcDir, resolvedFileName)
resolved, err := contentsOfCartfileResolved(resolvedFilePath)
if err != nil {
return false, err
}
desiredCacheContent := fmt.Sprintf("--Swift version: %s --Swift version \n --%s: %s --%s", swiftVersion, resolvedFileName, resolved, resolvedFileName)
return cacheContent == desiredCacheContent, nil
}
开发者ID:bitrise-steplib,项目名称:steps-carthage,代码行数:54,代码来源:main.go
示例5: IsSSHKeypairFileExistInDirectory
// IsSSHKeypairFileExistInDirectory ...
func IsSSHKeypairFileExistInDirectory(workdirPth string) bool {
privFilePath := fullSSHPrivateKeyFilePath(workdirPth)
pubFilePath := fullSSHPublicKeyFilePath(workdirPth)
exists, err := pathutil.IsPathExists(privFilePath)
if !exists || err != nil {
return false
}
exists, err = pathutil.IsPathExists(pubFilePath)
if !exists || err != nil {
return false
}
return true
}
开发者ID:bitrise-tools,项目名称:bitrise-machine,代码行数:15,代码来源:ssh_config.go
示例6: TestClonePluginSrc
func TestClonePluginSrc(t *testing.T) {
t.Log("example plugin - latest version")
{
pluginSource := examplePluginGitURL
versionTag := ""
destinationDir, err := pathutil.NormalizedOSTempDirPath("TestClonePluginSrc")
require.NoError(t, err)
exist, err := pathutil.IsPathExists(destinationDir)
require.NoError(t, err)
if exist {
err := os.RemoveAll(destinationDir)
require.NoError(t, err)
}
version, hash, err := clonePluginSrc(pluginSource, versionTag, destinationDir)
require.NoError(t, err)
require.NotNil(t, version)
require.NotEmpty(t, hash)
exist, err = pathutil.IsPathExists(destinationDir)
require.NoError(t, err)
require.Equal(t, true, exist)
}
t.Log("example plugin - 0.9.0 version")
{
pluginSource := examplePluginGitURL
versionTag := "0.9.0"
destinationDir, err := pathutil.NormalizedOSTempDirPath("TestClonePluginSrc")
require.NoError(t, err)
exist, err := pathutil.IsPathExists(destinationDir)
require.NoError(t, err)
if exist {
err := os.RemoveAll(destinationDir)
require.NoError(t, err)
}
version, hash, err := clonePluginSrc(pluginSource, versionTag, destinationDir)
require.NoError(t, err)
require.NotNil(t, version)
require.Equal(t, "0.9.0", version.String())
require.NotEmpty(t, hash)
exist, err = pathutil.IsPathExists(destinationDir)
require.NoError(t, err)
require.Equal(t, true, exist)
}
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:50,代码来源:install_test.go
示例7: ReadSpecStep
// ReadSpecStep ...
func ReadSpecStep(pth string) (stepmanModels.StepModel, error) {
if isExists, err := pathutil.IsPathExists(pth); err != nil {
return stepmanModels.StepModel{}, err
} else if !isExists {
return stepmanModels.StepModel{}, errors.New(fmt.Sprint("No file found at path", pth))
}
bytes, err := fileutil.ReadBytesFromFile(pth)
if err != nil {
return stepmanModels.StepModel{}, err
}
var stepModel stepmanModels.StepModel
if err := yaml.Unmarshal(bytes, &stepModel); err != nil {
return stepmanModels.StepModel{}, err
}
if err := stepModel.Normalize(); err != nil {
return stepmanModels.StepModel{}, err
}
if err := stepModel.Validate(false); err != nil {
return stepmanModels.StepModel{}, err
}
if err := stepModel.FillMissingDefaults(); err != nil {
return stepmanModels.StepModel{}, err
}
return stepModel, nil
}
开发者ID:bitrise-io,项目名称:bitrise-yml-converter,代码行数:32,代码来源:util.go
示例8: validate
func (configs ConfigsModel) validate() error {
if configs.XamarinSolution == "" {
return errors.New("No XamarinSolution parameter specified!")
}
if exist, err := pathutil.IsPathExists(configs.XamarinSolution); err != nil {
return fmt.Errorf("Failed to check if XamarinSolution exist at: %s, error: %s", configs.XamarinSolution, err)
} else if !exist {
return fmt.Errorf("XamarinSolution not exist at: %s", configs.XamarinSolution)
}
if configs.XamarinConfiguration == "" {
return errors.New("No XamarinConfiguration parameter specified!")
}
if configs.XamarinPlatform == "" {
return errors.New("No XamarinPlatform parameter specified!")
}
if configs.APIKey == "" {
return errors.New("No APIKey parameter specified!")
}
if configs.User == "" {
return errors.New("No User parameter specified!")
}
if configs.Devices == "" {
return errors.New("No Devices parameter specified!")
}
if configs.Series == "" {
return errors.New("No Series parameter specified!")
}
return nil
}
开发者ID:bitrise-steplib,项目名称:steps-xamarin-test-cloud-for-ios,代码行数:32,代码来源:main.go
示例9: readRouteMap
func readRouteMap() (SteplibRoutes, error) {
exist, err := pathutil.IsPathExists(getRoutingFilePath())
if err != nil {
return SteplibRoutes{}, err
} else if !exist {
return SteplibRoutes{}, nil
}
bytes, err := fileutil.ReadBytesFromFile(getRoutingFilePath())
if err != nil {
return SteplibRoutes{}, err
}
var routeMap map[string]string
if err := json.Unmarshal(bytes, &routeMap); err != nil {
return SteplibRoutes{}, err
}
routes := []SteplibRoute{}
for key, value := range routeMap {
routes = append(routes, SteplibRoute{
SteplibURI: key,
FolderAlias: value,
})
}
return routes, nil
}
开发者ID:godrei,项目名称:stepman,代码行数:27,代码来源:paths.go
示例10: GetConfigs
// GetConfigs ...
func GetConfigs() (ConfigsModel, error) {
configPth := getEnvmanConfigsFilePath()
defaultConfigs := createDefaultConfigsModel()
if isExist, err := pathutil.IsPathExists(configPth); err != nil {
return ConfigsModel{}, err
} else if !isExist {
return defaultConfigs, nil
}
bytes, err := fileutil.ReadBytesFromFile(configPth)
if err != nil {
return ConfigsModel{}, err
}
type ConfigsFileMode struct {
EnvBytesLimitInKB *int `json:"env_bytes_limit_in_kb,omitempty"`
EnvListBytesLimitInKB *int `json:"env_list_bytes_limit_in_kb,omitempty"`
}
var userConfigs ConfigsFileMode
if err := json.Unmarshal(bytes, &userConfigs); err != nil {
return ConfigsModel{}, err
}
if userConfigs.EnvBytesLimitInKB != nil {
defaultConfigs.EnvBytesLimitInKB = *userConfigs.EnvBytesLimitInKB
}
if userConfigs.EnvListBytesLimitInKB != nil {
defaultConfigs.EnvListBytesLimitInKB = *userConfigs.EnvListBytesLimitInKB
}
return defaultConfigs, nil
}
开发者ID:fbernardo,项目名称:envman,代码行数:35,代码来源:configs.go
示例11: destroy
func destroy(c *cli.Context) {
log.Infoln("Destroy")
additionalEnvs, err := config.CreateEnvItemsModelFromSlice(MachineParamsAdditionalEnvs.Get())
if err != nil {
log.Fatalf("Invalid Environment parameter: %s", err)
}
configModel, err := config.ReadMachineConfigFileFromDir(MachineWorkdir.Get(), additionalEnvs)
if err != nil {
log.Fatalln("Failed to read Config file: ", err)
}
isOK, err := pathutil.IsPathExists(path.Join(MachineWorkdir.Get(), "Vagrantfile"))
if err != nil {
log.Fatalln("Failed to check 'Vagrantfile' in the WorkDir: ", err)
}
if !isOK {
log.Fatalln("Vagrantfile not found in the WorkDir!")
}
log.Infof("configModel: %#v", configModel)
if err := doCleanup(configModel, "will-be-destroyed"); err != nil {
log.Fatalf("Failed to Cleanup: %s", err)
}
if err := doDestroy(configModel); err != nil {
log.Fatalf("Failed to Destroy: %s", err)
}
log.Infoln("=> Destroy DONE - OK")
}
开发者ID:bitrise-tools,项目名称:bitrise-machine,代码行数:33,代码来源:destroy.go
示例12: loadBitriseConfig
func loadBitriseConfig() (ConfigModel, error) {
if err := EnsureBitriseConfigDirExists(); err != nil {
return ConfigModel{}, err
}
configPth := getBitriseConfigFilePath()
if exist, err := pathutil.IsPathExists(configPth); err != nil {
return ConfigModel{}, err
} else if !exist {
return ConfigModel{}, nil
}
bytes, err := fileutil.ReadBytesFromFile(configPth)
if err != nil {
return ConfigModel{}, err
}
if len(bytes) == 0 {
return ConfigModel{}, errors.New("empty config file")
}
config := ConfigModel{}
if err := json.Unmarshal(bytes, &config); err != nil {
return ConfigModel{}, fmt.Errorf("failed to marshal config (%s), error: %s", string(bytes), err)
}
return config, nil
}
开发者ID:viktorbenei,项目名称:bitrise,代码行数:28,代码来源:configs.go
示例13: WriteStepSpecToFile
// WriteStepSpecToFile ...
func WriteStepSpecToFile(templateCollection models.StepCollectionModel, route SteplibRoute) error {
pth := GetStepSpecPath(route)
if exist, err := pathutil.IsPathExists(pth); err != nil {
log.Error("Failed to check path:", err)
return err
} else if !exist {
dir, _ := path.Split(pth)
err := os.MkdirAll(dir, 0777)
if err != nil {
return err
}
} else {
err := os.Remove(pth)
if err != nil {
return err
}
}
collection, err := generateStepLib(route, templateCollection)
if err != nil {
return err
}
bytes, err := json.MarshalIndent(collection, "", "\t")
if err != nil {
return err
}
return fileutil.WriteBytesToFile(pth, bytes)
}
开发者ID:bitrise-io,项目名称:stepman,代码行数:31,代码来源:util.go
示例14: PrepareForStepRun
// PrepareForStepRun ...
func (toolkit GoToolkit) PrepareForStepRun(step stepmanModels.StepModel, sIDData models.StepIDData, stepAbsDirPath string) error {
fullStepBinPath := stepBinaryCacheFullPath(sIDData)
// try to use cached binary, if possible
if sIDData.IsUniqueResourceID() {
if exists, err := pathutil.IsPathExists(fullStepBinPath); err != nil {
log.Warn("Failed to check cached binary for step, error: %s", err)
} else if exists {
log.Debugln("No need to compile, binary already exists")
return nil
}
}
// it's not cached, so compile it
if step.Toolkit == nil {
return errors.New("No Toolkit information specified in step")
}
if step.Toolkit.Go == nil {
return errors.New("No Toolkit.Go information specified in step")
}
packageName := step.Toolkit.Go.PackageName
return goBuildInIsolation(packageName, stepAbsDirPath, fullStepBinPath)
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:26,代码来源:golang.go
示例15: gitInitWithRemote
func gitInitWithRemote(cloneIntoDir, repositoryURL string) error {
gitCheckPath := filepath.Join(cloneIntoDir, ".git")
if exist, err := pathutil.IsPathExists(gitCheckPath); err != nil {
return fmt.Errorf("Failed to file path (%s), err: %s", gitCheckPath, err)
} else if exist {
return fmt.Errorf(".git folder already exists in the destination dir (%s)", gitCheckPath)
}
if err := os.MkdirAll(cloneIntoDir, 0777); err != nil {
return fmt.Errorf("Failed to create the clone_destination_dir at: %s", cloneIntoDir)
}
if err := gitInit(cloneIntoDir); err != nil {
return fmt.Errorf("Could not init git repository, err: %s", cloneIntoDir)
}
if err := gitAddRemote(cloneIntoDir, repositoryURL); err != nil {
return fmt.Errorf("Could not add remote, err: %s", err)
}
if err := gitFetch(cloneIntoDir); err != nil {
return fmt.Errorf("Could not fetch from repository, err: %s", err)
}
return nil
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:26,代码来源:git.go
示例16: FindProvProfileByUUID
// FindProvProfileByUUID ...
func FindProvProfileByUUID(provProfileUUID string) (ProvisioningProfileFileInfoModel, error) {
absProvProfileDirPath, err := pathutil.AbsPath(provProfileSystemDirPath)
if err != nil {
return ProvisioningProfileFileInfoModel{}, fmt.Errorf("Failed to get Absolute path of Provisioning Profiles dir: %s", err)
}
// iOS / .mobileprovision
{
mobileProvPth := filepath.Join(absProvProfileDirPath, provProfileUUID+".mobileprovision")
exist, err := pathutil.IsPathExists(mobileProvPth)
if !exist || err != nil {
log.Debugf("No mobileprovision file found at: %s | err: %s", mobileProvPth, err)
} else {
provProfileData, err := CreateProvisioningProfileModelFromFile(mobileProvPth)
if err != nil {
return ProvisioningProfileFileInfoModel{},
fmt.Errorf("Failed to read Provisioning Profile infos from file (path: %s), error: %s",
mobileProvPth, err)
}
return ProvisioningProfileFileInfoModel{
Path: mobileProvPth,
ProvisioningProfileInfo: provProfileData,
}, nil
}
}
// Mac / .provisionprofile
{
macProvProfPth := filepath.Join(absProvProfileDirPath, provProfileUUID+".provisionprofile")
exist, err := pathutil.IsPathExists(macProvProfPth)
if !exist || err != nil {
log.Debugf("No provisionprofile file found at: %s | err: %s", macProvProfPth, err)
return ProvisioningProfileFileInfoModel{}, fmt.Errorf("Failed to find Provisioning Profile with UUID: %s", provProfileUUID)
}
provProfileData, err := CreateProvisioningProfileModelFromFile(macProvProfPth)
if err != nil {
return ProvisioningProfileFileInfoModel{},
fmt.Errorf("Failed to read Provisioning Profile infos from file (path: %s), error: %s",
macProvProfPth, err)
}
return ProvisioningProfileFileInfoModel{
Path: macProvProfPth,
ProvisioningProfileInfo: provProfileData,
}, nil
}
}
开发者ID:bitrise-tools,项目名称:codesigndoc,代码行数:48,代码来源:provprofile.go
示例17: validatePath
func validatePath(pth string) error {
if exist, err := pathutil.IsPathExists(pth); err != nil {
return fmt.Errorf("failed to check bitrise-plugin.yml path (%s), error: %s", pth, err)
} else if !exist {
return fmt.Errorf("no bitrise-plugin.yml found at (%s)", pth)
}
return nil
}
开发者ID:godrei,项目名称:bitrise,代码行数:8,代码来源:install.go
示例18: deleteFileIfExists
func deleteFileIfExists(pth string) error {
isExists, err := pathutil.IsPathExists(pth)
if err != nil {
return err
}
if !isExists {
return nil
}
return os.Remove(pth)
}
开发者ID:bitrise-tools,项目名称:bitrise-machine,代码行数:10,代码来源:ssh_config.go
示例19: RemoveDir
// RemoveDir ...
func RemoveDir(dirPth string) error {
if exist, err := pathutil.IsPathExists(dirPth); err != nil {
return err
} else if exist {
if err := os.RemoveAll(dirPth); err != nil {
return err
}
}
return nil
}
开发者ID:bazscsa,项目名称:envman,代码行数:11,代码来源:file.go
示例20: RemoveFile
// RemoveFile ...
func RemoveFile(pth string) error {
if exist, err := pathutil.IsPathExists(pth); err != nil {
return err
} else if exist {
if err := os.Remove(pth); err != nil {
return err
}
}
return nil
}
开发者ID:bazscsa,项目名称:envman,代码行数:11,代码来源:file.go
注:本文中的github.com/bitrise-io/go-utils/pathutil.IsPathExists函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论