Skip to content

Commit 1fed472

Browse files
author
George Haberis
committed
small refactor to build script
1 parent 90a2d9a commit 1fed472

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

ab-testing/abTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const ABTests: ABTest[] = [
2929
status: 'ON',
3030
expirationDate: '2050-12-30',
3131
type: 'client',
32-
audienceSize: 5 / 100,
32+
audienceSize: 0 / 100,
3333
groups: ['control', 'variant'],
3434
shouldForceMetricsCollection: true,
3535
},
@@ -41,7 +41,7 @@ export const ABTests: ABTest[] = [
4141
status: 'ON',
4242
expirationDate: '2050-12-30',
4343
type: 'server',
44-
audienceSize: 5 / 100,
44+
audienceSize: 0 / 100,
4545
groups: ['control', 'variant'],
4646
shouldForceMetricsCollection: true,
4747
},

ab-testing/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"tasks": {
33
"validate": "deno run scripts/validation/index.ts",
44
"deploy": "deno run --allow-read=dist --allow-env=FASTLY_AB_TESTING_CONFIG --allow-net=api.fastly.com:443 scripts/deploy/index.ts --mvts=dist/mvts.json --ab-tests=dist/ab-tests.json",
5-
"build": "deno run --allow-env=FASTLY_AB_TESTING_CONFIG,FASTLY_API_TOKEN --allow-net=api.fastly.com:443 --allow-write=dist scripts/build/index.ts --mvts=mvts.json --ab-tests=ab-tests.json"
5+
"build": "deno run --allow-write=dist --allow-env=FASTLY_AB_TESTING_CONFIG,FASTLY_API_TOKEN --allow-net=api.fastly.com:443 scripts/build/index.ts --mvts=dist/mvts.json --ab-tests=dist/ab-tests.json"
66
},
77
"imports": {
88
"@std/assert": "jsr:@std/assert@^1.0.13",

ab-testing/scripts/build/index.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,16 @@ const mvtDictArray = Array.from(
3838

3939
console.log(`Writing ${mvtDictArray.length} MVT groups to ${flags['mvts']}`);
4040

41-
const distDirName = 'dist';
42-
43-
// Ensure the dist folder exists
44-
await Deno.mkdir(distDirName, { recursive: true });
45-
46-
// Build absolute output path inside dist/
47-
const abTestsPath = `${distDirName}/${flags['ab-tests']}`;
41+
// Ensure the build's destination folder path exists
42+
for (const path of [flags['mvts'], flags['ab-tests']]) {
43+
await Deno.mkdir(dirname(path), { recursive: true });
44+
}
4845

4946
// write the abTestDictArray to a file
5047
await Deno.writeTextFile(
51-
abTestsPath,
48+
flags['ab-tests'],
5249
JSON.stringify(abTestGroupKeyValues, null, 2),
5350
);
5451

55-
// Build absolute output pats inside dist/
56-
const mvtsPath = `${distDirName}/${flags['mvts']}`;
57-
5852
// write the mvtKVsArray to a file
59-
await Deno.writeTextFile(mvtsPath, JSON.stringify(mvtDictArray, null, 2));
53+
await Deno.writeTextFile(flags['mvts'], JSON.stringify(mvtDictArray, null, 2));

0 commit comments

Comments
 (0)