Skip to content

Commit 656e7d6

Browse files
committed
Improve data extension pattern checking
1 parent 62619b2 commit 656e7d6

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

extensions/ql-vscode/src/data-extensions-editor/extension-packs.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,24 @@ async function pickNewModelFile(
133133
return undefined;
134134
}
135135

136-
const dataExtensionPatterns = qlpack.dataExtensions ?? [];
137-
if (!Array.isArray(dataExtensionPatterns)) {
136+
const dataExtensionPatternsValue = qlpack.dataExtensions ?? [];
137+
if (
138+
!(
139+
Array.isArray(dataExtensionPatternsValue) ||
140+
typeof dataExtensionPatternsValue === "string"
141+
)
142+
) {
138143
void showAndLogErrorMessage(
139-
`Expected 'dataExtensions' to be an array in ${qlpackPath}`,
144+
`Expected 'dataExtensions' to be a string or an array in ${qlpackPath}`,
140145
);
141146
return undefined;
142147
}
143148

149+
// The YAML allows either a string or an array of strings
150+
const dataExtensionPatterns = Array.isArray(dataExtensionPatternsValue)
151+
? dataExtensionPatternsValue
152+
: [dataExtensionPatternsValue];
153+
144154
const filename = await window.showInputBox(
145155
{
146156
title: "Enter the name of the new model file",
@@ -152,10 +162,11 @@ async function pickNewModelFile(
152162
return "File already exists";
153163
}
154164

155-
const isInExtensionPack = !relative(extensionPackPath, path).startsWith(
156-
"..",
157-
);
158-
if (!isInExtensionPack) {
165+
const notInExtensionPack = !relative(
166+
extensionPackPath,
167+
path,
168+
).startsWith("..");
169+
if (notInExtensionPack) {
159170
return "File must be in the extension pack";
160171
}
161172

0 commit comments

Comments
 (0)