mihaiolteanu / mugur

Configurator for QMK compatible keyboards

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build fails when mugur-keymap-name does not exists (only the first time)

nico202 opened this issue · comments

mugur/mugur.el

Line 814 in b8ebfd1

(make-directory it))

Hi! Here make-directory returns nil, so and returns nil and concat fails. The second time the function is run, the folder has already been created to it does work

Just adding a t after it should work

(and (or (file-directory-p it)
                     (make-directory it)
                     t)
                 it)

Good find!

Maybe the solution just complicates stuff.
I was expecting (wrongly) for make-directory to return the newly created path.

Anyway, how about,

(with-temp-file
    (let ((fparents                     ;Create the FILE's parents path
           (concat (file-name-as-directory mugur-qmk-path)
                   (file-name-as-directory "keyboards")
                   (file-name-as-directory mugur-keyboard-name)
                   (file-name-as-directory "keymaps")
                   (file-name-as-directory mugur-keymap-name))))
      (unless (file-directory-p fparents)
        ;; Only create the `mugur-keymap-name' if it doesn't already exist, the
        ;; rest of the parents should exist in a valid qmk_firmare source code.
        (make-directory fparents))
      (concat fparents file))
    (insert contents))

Should this be clearer?

Should this be clearer?

Sure it is, I'll fix the PR accordingly