Skip to content

Commit

Permalink
create key directory if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Feb 8, 2024
1 parent 45787c0 commit 22d21cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"context"
"encoding/json"
"os"
"path/filepath"

"github.com/libp2p/go-libp2p/core/crypto"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -138,6 +139,10 @@ func generatePrivateKey(path string) (crypto.PrivKey, error) {
if err != nil {
return nil, err
}
err = os.MkdirAll(filepath.Dir(path), 0755)
if err != nil {
return nil, err
}
return key, os.WriteFile(path, data, 0644)
}

Expand Down

0 comments on commit 22d21cd

Please sign in to comment.