@@ -97,7 +97,11 @@ func getPrefsDirectory() string {
97
97
var info os.FileInfo
98
98
var err error
99
99
if info ,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
+ if err := os .MkdirAll (folder ,0755 );err != nil {
102
+ logrus .Fatalf ("creating folder: %s" ,folder )
103
+ }
104
+ info ,_ = os .Stat (folder )
101
105
}
102
106
103
107
if ! info .IsDir () {
@@ -118,16 +122,23 @@ type Alfred struct {
118
122
119
123
func NewAlfred ()* Alfred {
120
124
a := & Alfred {
121
- BuildDir :viper .GetString ("workflow.folder" ),
125
+ BuildDir :func (a ,b string )string {
126
+ pwd ,_ := filepath .Abs ("." )
127
+ return path .Join (pwd ,a ,b )
128
+ }(viper .GetString ("ak_folder" ),viper .GetString ("workflow.folder" )),
122
129
}
130
+ logrus .Debugf ("build dir: %s" ,a .BuildDir )
123
131
124
132
a .PrefsDir = getPrefsDirectory ()
125
133
logrus .Debugf ("prefs dir: %s" ,a .PrefsDir )
134
+
126
135
a .WorkflowsPath = path .Join (a .PrefsDir ,"Alfred.alfredpreferences/workflows" )
136
+ a .WorkflowPath ,_ = filepath .Abs ("." )
127
137
logrus .Debugf ("workflows path: %s" ,a .WorkflowsPath )
128
138
129
- a .WorkflowPath ,_ = filepath .Abs ("." )
130
139
plistFile := path .Join (a .BuildDir ,"info.plist" )
140
+ logrus .Debugf ("plist file: %s" ,plistFile )
141
+
131
142
if fileExists (plistFile ) {
132
143
plist := LoadPlist (plistFile )
133
144
workflowVersion := plist ["version" ]
@@ -336,16 +347,16 @@ func (a *Alfred) Build() error {
336
347
}
337
348
338
349
func (a * Alfred )Pack ()error {
350
+ logrus .Debugf ("Changing directory to %s" ,a .BuildDir )
339
351
if err := os .Chdir (a .BuildDir );err != nil {
340
352
return err
341
353
}
342
354
343
- pwd ,_ := filepath .Abs ("." )
344
- zipfile := path .Join (pwd ,".." ,a .ZipName )
355
+ zipfile := path .Join (a .BuildDir ,".." ,a .ZipName )
345
356
logrus .Infof ("Creating archive %s" ,zipfile )
346
357
Run ("zip" ,"-r" ,zipfile ,"." )
347
358
348
- if err := os .Chdir (pwd );err != nil {
359
+ if err := os .Chdir (path . Join ( a . BuildDir , ".." ) );err != nil {
349
360
return err
350
361
}
351
362