Skip to content

Commit 2914236

Browse files
author
Tyler Waters
committed
Generate files first, then write them out
1 parent fb54625 commit 2914236

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/generator.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ const generateOperationFile = (config, operation, operation_name) => new Promise
126126
* @param {Object} config Configuration options
127127
* @returns {Promise}
128128
*/
129-
const generateOperationFiles = config => new Promise((resolve, reject) => {
129+
130+
const generateOperationFiles = config => {
130131
const files = {};
131-
_.each(config.data.openapi.paths, (path, path_name) => {
132+
_.forEach(config.data.openapi.paths, (path, path_name) => {
132133
const operation_name = path.endpointName;
133134
if (files[operation_name] === undefined) {
134135
files[operation_name] = [];
@@ -142,11 +143,12 @@ const generateOperationFiles = config => new Promise((resolve, reject) => {
142143
subresource: (path_name.substring(operation_name.length+1) || '/').replace(/}/g, '').replace(/{/g, ':')
143144
});
144145

145-
Promise.all(
146-
_.map(files, (operation, operation_name) => generateOperationFile(config, operation, operation_name))
147-
).then(resolve).catch(reject);
148146
});
149-
});
147+
148+
return Promise.all(
149+
_.map(files, (operation, operation_name) => generateOperationFile(config, operation, operation_name))
150+
);
151+
};
150152

151153
/**
152154
* Generates the directory structure.

0 commit comments

Comments
 (0)