From 270eb47068c2d2d90622e52c8823e7d129f87c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Tue, 30 May 2023 16:41:11 +0200 Subject: [PATCH 1/3] #945: corrected expected SQL to have uppercased "AS" statements --- test/resources/9999999/query/build-expected.sql | 2 +- test/resources/9999999/query/get-expected.sql | 2 +- test/resources/9999999/query/patch-expected.sql | 2 +- test/resources/9999999/query/post-expected.sql | 2 +- test/resources/9999999/query/template-expected.sql | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/resources/9999999/query/build-expected.sql b/test/resources/9999999/query/build-expected.sql index 276ccd7aa..4385e76e8 100644 --- a/test/resources/9999999/query/build-expected.sql +++ b/test/resources/9999999/query/build-expected.sql @@ -1,5 +1,5 @@ SELECT - SubscriberKey as testField + SubscriberKey AS testField FROM _Subscribers WHERE diff --git a/test/resources/9999999/query/get-expected.sql b/test/resources/9999999/query/get-expected.sql index e78525408..2a32f5fad 100644 --- a/test/resources/9999999/query/get-expected.sql +++ b/test/resources/9999999/query/get-expected.sql @@ -1,5 +1,5 @@ SELECT - SubscriberKey as testField + SubscriberKey AS testField FROM _Subscribers WHERE diff --git a/test/resources/9999999/query/patch-expected.sql b/test/resources/9999999/query/patch-expected.sql index e78525408..2a32f5fad 100644 --- a/test/resources/9999999/query/patch-expected.sql +++ b/test/resources/9999999/query/patch-expected.sql @@ -1,5 +1,5 @@ SELECT - SubscriberKey as testField + SubscriberKey AS testField FROM _Subscribers WHERE diff --git a/test/resources/9999999/query/post-expected.sql b/test/resources/9999999/query/post-expected.sql index 8020314ea..4148833c4 100644 --- a/test/resources/9999999/query/post-expected.sql +++ b/test/resources/9999999/query/post-expected.sql @@ -1,4 +1,4 @@ SELECT - SubscriberKey as testField + SubscriberKey AS testField FROM _Subscribers diff --git a/test/resources/9999999/query/template-expected.sql b/test/resources/9999999/query/template-expected.sql index 0ed1dc1cc..06aae9b31 100644 --- a/test/resources/9999999/query/template-expected.sql +++ b/test/resources/9999999/query/template-expected.sql @@ -1,5 +1,5 @@ SELECT - SubscriberKey as testField + SubscriberKey AS testField FROM _Subscribers WHERE From 749364734cf3dddaa2c14bb03d04faeb55d1292a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Tue, 30 May 2023 16:57:57 +0200 Subject: [PATCH 2/3] #945: ensure we re-initialize the prettier config for each file extension --- lib/util/file.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/util/file.js b/lib/util/file.js index d4d9c6946..89206f83e 100644 --- a/lib/util/file.js +++ b/lib/util/file.js @@ -517,9 +517,10 @@ const File = { * @param {string} [filetype='html'] filetype ie. JSON or SSJS * @returns {Promise.} 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 @@ -547,5 +548,6 @@ const File = { }; const FileFs = { ...fs, ...File }; FileFs.prettierConfig = null; +FileFs.prettierConfigFileType = null; module.exports = FileFs; From 575554d00f56112e0e4897df15d37d9c949f7531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Tue, 30 May 2023 16:59:01 +0200 Subject: [PATCH 3/3] #945: only initialize prettier config if we actually plan on saving files - not for caching --- lib/metadataTypes/Asset.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/metadataTypes/Asset.js b/lib/metadataTypes/Asset.js index 6c6b13dc6..3ff861cce 100644 --- a/lib/metadataTypes/Asset.js +++ b/lib/metadataTypes/Asset.js @@ -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)