From a4465f9cb8653be8d997e1c891c751708f6b3a52 Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Fri, 30 Aug 2019 11:40:51 -0500 Subject: [PATCH 1/2] :bug: Fixing #21 path resolution for templates Fixed issue where generator would not generate in the proper folders on Windows 10, Node 10.16.3, NPM: 6.9.0. --- lib/codegen.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/codegen.js b/lib/codegen.js index e19efd7..5a151dd 100644 --- a/lib/codegen.js +++ b/lib/codegen.js @@ -83,7 +83,9 @@ const generateOperationFile = (config, operation, operation_name) => new Promise if (err) return reject(err); const subdir = config.root.replace(new RegExp(`${config.templates_dir}[/]?`),''); const new_filename = config.file_name.replace('___', operation_name); - const target_file = path.resolve(config.target_dir, subdir, new_filename); + const target_file_path = path.resolve(config.target_dir, path.basename(subdir)); + xfs.mkdirpSync(target_file_path) + const target_file = path.resolve(target_file_path, new_filename); const template = Handlebars.compile(data.toString()); const content = template({ From 24a3675e42b5b62d178289d32339f40fd01af117 Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Fri, 30 Aug 2019 11:49:59 -0500 Subject: [PATCH 2/2] Include nested folders --- lib/codegen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codegen.js b/lib/codegen.js index 5a151dd..d05f45e 100644 --- a/lib/codegen.js +++ b/lib/codegen.js @@ -83,7 +83,7 @@ const generateOperationFile = (config, operation, operation_name) => new Promise if (err) return reject(err); const subdir = config.root.replace(new RegExp(`${config.templates_dir}[/]?`),''); const new_filename = config.file_name.replace('___', operation_name); - const target_file_path = path.resolve(config.target_dir, path.basename(subdir)); + const target_file_path = path.join(config.target_dir, subdir.replace(config.templates_dir, '')); xfs.mkdirpSync(target_file_path) const target_file = path.resolve(target_file_path, new_filename); const template = Handlebars.compile(data.toString());