Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/945 queries not correctly formatted when other types were retrieved first #946

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class Asset extends MetadataType {
static async retrieve(retrieveDir, _, subTypeArr, key) {
const items = [];
subTypeArr ||= this._getSubTypes();
await File.initPrettier();
if (retrieveDir) {
await File.initPrettier();
}
// loop through subtypes and return results of each subType for caching (saving is handled per subtype)
for (const subType of subTypeArr) {
// each subtype contains multiple different specific types (images contains jpg and png for example)
Expand Down
8 changes: 5 additions & 3 deletions lib/util/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,10 @@ const File = {
* @param {string} [filetype='html'] filetype ie. JSON or SSJS
* @returns {Promise.<boolean>} success of config load
*/
async initPrettier(filetype) {
if (FileFs.prettierConfig === null) {
filetype ||= 'html';
async initPrettier(filetype = 'html') {
if (FileFs.prettierConfig === null || FileFs.prettierConfigFileType !== filetype) {
// run this if no config was yet found or if the filetype previously used to initialize it differs (because it results in a potentially different config!)
FileFs.prettierConfigFileType = filetype;
try {
// pass in project dir with fake index.html to avoid "no parser" error
// by using process.cwd we are limiting ourselves to a config in the project root
Expand Down Expand Up @@ -547,5 +548,6 @@ const File = {
};
const FileFs = { ...fs, ...File };
FileFs.prettierConfig = null;
FileFs.prettierConfigFileType = null;

module.exports = FileFs;
2 changes: 1 addition & 1 deletion test/resources/9999999/query/build-expected.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
SubscriberKey as testField
SubscriberKey AS testField
FROM
_Subscribers
WHERE
Expand Down
2 changes: 1 addition & 1 deletion test/resources/9999999/query/get-expected.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
SubscriberKey as testField
SubscriberKey AS testField
FROM
_Subscribers
WHERE
Expand Down
2 changes: 1 addition & 1 deletion test/resources/9999999/query/patch-expected.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
SubscriberKey as testField
SubscriberKey AS testField
FROM
_Subscribers
WHERE
Expand Down
2 changes: 1 addition & 1 deletion test/resources/9999999/query/post-expected.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT
SubscriberKey as testField
SubscriberKey AS testField
FROM
_Subscribers
2 changes: 1 addition & 1 deletion test/resources/9999999/query/template-expected.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
SubscriberKey as testField
SubscriberKey AS testField
FROM
_Subscribers
WHERE
Expand Down