File tree 2 files changed +20
-5
lines changed
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -262,3 +262,9 @@ func LoadProjectFile(file *paths.Path) (*Project, error) {
262
262
}
263
263
return res , nil
264
264
}
265
+
266
+ // SaveProjectFile save the sketch project to a file
267
+ func (s * Sketch ) SaveProjectFile () error {
268
+ projectFile := s .GetProjectPath ()
269
+ return projectFile .WriteFile ([]byte (s .Project .AsYaml ()))
270
+ }
Original file line number Diff line number Diff line change @@ -101,13 +101,10 @@ func New(path *paths.Path) (*Sketch, error) {
101
101
AdditionalFiles : paths.PathList {},
102
102
RootFolderFiles : paths.PathList {},
103
103
Metadata : new (Metadata ),
104
+ Project : & Project {},
104
105
}
105
106
106
- projectFile := path .Join ("sketch.yaml" )
107
- if ! projectFile .Exist () {
108
- projectFile = path .Join ("sketch.yml" )
109
- }
110
- if projectFile .Exist () {
107
+ if projectFile := sketch .GetProjectPath (); projectFile .Exist () {
111
108
prj , err := LoadProjectFile (projectFile )
112
109
if err != nil {
113
110
return nil , fmt .Errorf ("%s %w" , tr ("error loading sketch project file:" ), err )
@@ -287,6 +284,18 @@ func (s *Sketch) checkSketchCasing() error {
287
284
return nil
288
285
}
289
286
287
+ // GetProjectPath returns the path to the sketch project file (sketch.yaml or sketch.yml)
288
+ func (s * Sketch ) GetProjectPath () * paths.Path {
289
+ projectFile := s .FullPath .Join ("sketch.yaml" )
290
+ if ! projectFile .Exist () {
291
+ alternateProjectFile := s .FullPath .Join ("sketch.yml" )
292
+ if alternateProjectFile .Exist () {
293
+ return alternateProjectFile
294
+ }
295
+ }
296
+ return projectFile
297
+ }
298
+
290
299
// InvalidSketchFolderNameError is returned when the sketch directory doesn't match the sketch name
291
300
type InvalidSketchFolderNameError struct {
292
301
SketchFolder * paths.Path
You can’t perform that action at this time.
0 commit comments