Skip to content

Commit

Permalink
testing: remove extension in getGithubSamplesGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Nov 1, 2024
1 parent 24cf613 commit d175ed1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/testing/github-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { extname, join } from 'node:path';
import type { GitHubMatrixGroup } from './github-matrix.js';
import { getUnknownGitHubMatrixGroupProperties } from './github-matrix.js';

export const getGithubSamplesGroups = async (samplesGroupFolder: string): Promise<string[]> => {
export const getGithubSamplesGroups = async (samplesGroupFolder: string, keepExtensions = false): Promise<string[]> => {
const samplesFolderContent = await readdir(samplesGroupFolder);
return samplesFolderContent.filter(sample => ['.json', '.js', '.ts', ''].includes(extname(sample)));
return samplesFolderContent
.filter(sample => ['.json', '.js', '.ts', ''].includes(extname(sample)))
.map(sample => (keepExtensions ? sample : sample.split('.')[0]));
};

export const getGithubSamplesGroup = async (
Expand All @@ -14,7 +16,7 @@ export const getGithubSamplesGroup = async (
): Promise<{ samples: GitHubMatrixGroup; warnings: string[] }> => {
const warnings: string[] = [];
let samples: GitHubMatrixGroup = {};
const samplesFolderContent = await getGithubSamplesGroups(samplesGroupFolder);
const samplesFolderContent = await getGithubSamplesGroups(samplesGroupFolder, true);
if (samplesFolderContent.includes(`${group}.js`) || samplesFolderContent.includes(`${group}.ts`)) {
const jsGroup: { default: GitHubMatrixGroup } = await import(join(samplesGroupFolder, `${group}.js`));
samples = Object.fromEntries(Object.entries(jsGroup.default).map(([sample, value]) => [sample, { ...value, 'samples-group': group }]));
Expand Down

0 comments on commit d175ed1

Please sign in to comment.