From 365e780055c7037908c39af16ca668d116f5d448 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sat, 19 Oct 2019 18:40:47 +0200 Subject: [PATCH] Does not raise on missing directories. --- src/service/environment.cr | 2 ++ src/service/service.cr | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/service/environment.cr b/src/service/environment.cr index e64b917..c6d915e 100644 --- a/src/service/environment.cr +++ b/src/service/environment.cr @@ -38,6 +38,8 @@ class Environment class_getter all = [@@root] of Environment def self.load(path) + return unless Dir.exists? path + Dir.each_child path do |child| unless child.match /\.spec$/ next diff --git a/src/service/service.cr b/src/service/service.cr index 9c8c9f9..cf81951 100644 --- a/src/service/service.cr +++ b/src/service/service.cr @@ -1,5 +1,6 @@ require "yaml" require "colorize" +require "file_utils" require "./service_definition.cr" require "./environment.cr" @@ -296,6 +297,8 @@ class Service class_getter all = [] of Service def self.load(path) + return unless Dir.exists? path + Dir.each_child path do |child| unless child.match /\.spec$/ next @@ -312,6 +315,7 @@ class Service end def write(path) + FileUtils.mkdir_p "#{path}" File.write "#{path}/#{name}.#{@environment.name}.spec", to_spec end