Skip to content

Commit 64c3f5c

Browse files
committed
chore: show a multi-line queries in a single line
1 parent ca39a92 commit 64c3f5c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/cli.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ const loadConfig = (endpointsFile) => {
2121
}
2222
};
2323

24+
// "SELECT *\n FROM foo" => "SELECT * FROM foo"
25+
const flattenQuery = (query) => query.replace(/\n[ ]*/g, ' ');
26+
2427
const createEndpoints = async (destDir, fileName, config) => {
2528
console.log('Generate', fileName);
2629
const resultFile = path.join(destDir, fileName);
2730

2831
for (let endpoint of config) {
2932
if (endpoint.hasOwnProperty('get')) {
30-
console.log('GET', endpoint.path, '=>', endpoint.get);
33+
console.log('GET', endpoint.path, '=>', flattenQuery(endpoint.get));
3134
}
3235
if (endpoint.hasOwnProperty('post')) {
33-
console.log('POST', endpoint.path, '=>', endpoint.post);
36+
console.log('POST', endpoint.path, '=>', flattenQuery(endpoint.post));
3437
}
3538
}
3639

@@ -56,7 +59,7 @@ const createEndpoints = async (destDir, fileName, config) => {
5659

5760
// "SELECT *\n FROM foo" => "'SELECT * FROM foo'"
5861
"formatQuery": (query) => {
59-
return "'" + query.replace(/\n[ ]*/g, ' ') + "'";
62+
return "'" + flattenQuery(query) + "'";
6063
}
6164
}
6265
);

0 commit comments

Comments
 (0)