Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0925b6f

Browse files
committed
fix(alfred): build folder relative path
1 parenta53af68 commit0925b6f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

‎alfred/alfred.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ func getPrefsDirectory() string {
9797
varinfo os.FileInfo
9898
varerrerror
9999
ifinfo,err=os.Stat(folder);err!=nil {
100-
logrus.Fatalf("creating folder: %s",folder)
100+
logrus.Infof("folder %s does not exist, creating it",folder)
101+
iferr:=os.MkdirAll(folder,0755);err!=nil {
102+
logrus.Fatalf("creating folder: %s",folder)
103+
}
104+
info,_=os.Stat(folder)
101105
}
102106

103107
if!info.IsDir() {
@@ -118,16 +122,23 @@ type Alfred struct {
118122

119123
funcNewAlfred()*Alfred {
120124
a:=&Alfred{
121-
BuildDir:viper.GetString("workflow.folder"),
125+
BuildDir:func(a,bstring)string {
126+
pwd,_:=filepath.Abs(".")
127+
returnpath.Join(pwd,a,b)
128+
}(viper.GetString("ak_folder"),viper.GetString("workflow.folder")),
122129
}
130+
logrus.Debugf("build dir: %s",a.BuildDir)
123131

124132
a.PrefsDir=getPrefsDirectory()
125133
logrus.Debugf("prefs dir: %s",a.PrefsDir)
134+
126135
a.WorkflowsPath=path.Join(a.PrefsDir,"Alfred.alfredpreferences/workflows")
136+
a.WorkflowPath,_=filepath.Abs(".")
127137
logrus.Debugf("workflows path: %s",a.WorkflowsPath)
128138

129-
a.WorkflowPath,_=filepath.Abs(".")
130139
plistFile:=path.Join(a.BuildDir,"info.plist")
140+
logrus.Debugf("plist file: %s",plistFile)
141+
131142
iffileExists(plistFile) {
132143
plist:=LoadPlist(plistFile)
133144
workflowVersion:=plist["version"]
@@ -336,16 +347,16 @@ func (a *Alfred) Build() error {
336347
}
337348

338349
func (a*Alfred)Pack()error {
350+
logrus.Debugf("Changing directory to %s",a.BuildDir)
339351
iferr:=os.Chdir(a.BuildDir);err!=nil {
340352
returnerr
341353
}
342354

343-
pwd,_:=filepath.Abs(".")
344-
zipfile:=path.Join(pwd,"..",a.ZipName)
355+
zipfile:=path.Join(a.BuildDir,"..",a.ZipName)
345356
logrus.Infof("Creating archive %s",zipfile)
346357
Run("zip","-r",zipfile,".")
347358

348-
iferr:=os.Chdir(pwd);err!=nil {
359+
iferr:=os.Chdir(path.Join(a.BuildDir,".."));err!=nil {
349360
returnerr
350361
}
351362

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp