From 85e33bbe90e66cfe4d106b70255cde9b28abda94 Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Mon, 26 Feb 2018 20:02:23 -0800 Subject: [PATCH] Simple pre-flight checks More of this to come ... --- pkg/pkg.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/pkg.go b/pkg/pkg.go index 16ef817..62b4e68 100644 --- a/pkg/pkg.go +++ b/pkg/pkg.go @@ -1,8 +1,18 @@ package pkg -import "fmt" +import ( + "fmt" + + "mcquay.me/fs" +) // Create traverses the contents of dir and emits a valid pkg, signed by id func Create(dir, id string) error { + if !fs.Exists(dir) { + return fmt.Errorf("%q: doesn't exist", dir) + } + if !fs.IsDir(dir) { + return fmt.Errorf("%q: is not a directory", dir) + } return fmt.Errorf("creating package from %q for %q: NYI", dir, id) }