Skip to content

Commit

Permalink
examples: get dirs dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed May 9, 2024
1 parent 462deb0 commit 3ed1606
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@
import path from 'node:path';
import fs from 'node:fs';
import { ExecSyncOptions, execSync } from 'node:child_process';
import fg from 'fast-glob';
import pkg from '../package.json';

const isCI = Boolean(process.env.CI);
const dir = process.argv[2];
const dirs = dir
? [dir]
: [
'basic', // prettier-ignore
'cucumber-style',
'decorators',
'esm',
];
const dirs = dir ? [dir] : getExampleDirs();
const generatedTar = `playwright-bdd-${pkg.version}.tgz`;

buildAndInstallPlaywrightBdd();
Expand Down Expand Up @@ -51,3 +45,13 @@ function runCmd(cmd: string, opts: ExecSyncOptions = {}) {
console.log(`Running: ${cmd}`); // eslint-disable-line no-console
execSync(cmd, { ...opts, stdio: 'inherit' });
}

function getExampleDirs() {
return fg
.sync('**', {
cwd: 'examples',
deep: 1,
onlyDirectories: true,
})
.filter((dir) => dir !== 'node_modules');
}

0 comments on commit 3ed1606

Please sign in to comment.