diff --git a/bin/d2l-test-runner.js b/bin/d2l-test-runner.js index 310a585a..99feeda5 100755 --- a/bin/d2l-test-runner.js +++ b/bin/d2l-test-runner.js @@ -1,8 +1,8 @@ #!/usr/bin/env node import commandLineArgs from 'command-line-args'; +import { execSync } from 'node:child_process'; import process from 'node:process'; import { runner } from '../src/server/cli/test-runner.js'; -import { execSync } from 'node:child_process'; const { argv, stdout } = process; const cli = commandLineArgs({ name: 'subcommand', defaultOption: true }, { stopAtFirstUnknown: true, argv }); @@ -24,8 +24,10 @@ if (cli.subcommand === 'vdiff') { await migrate.start(vdiff._unknown); } else if (vdiff.subcommand === 'migrate-local') { + const { pattern = './**' } = commandLineArgs({ name: 'pattern', type: String, defaultOption: true }, { partial: true, argv: vdiff._unknown || [] }); + execSync('npm install @brightspace-ui/visual-diff@14 --no-save'); - execSync('npx mocha \'./**/*.visual-diff.js\' -t 10000 --golden'); + execSync(`npx mocha '${pattern}/*.visual-diff.js' -t 10000 --golden`); const { migrate } = await import('../src/server/cli/vdiff/migrate.js'); await migrate.start(vdiff._unknown, true); diff --git a/src/server/cli/vdiff/migrate.js b/src/server/cli/vdiff/migrate.js index c7fae890..863a261c 100755 --- a/src/server/cli/vdiff/migrate.js +++ b/src/server/cli/vdiff/migrate.js @@ -37,7 +37,10 @@ async function start(argv = [], local = false) { await mkdir(newDir, { recursive: true }); return rename(file, join(newDir, newName)); })); - return rm(normalize(join(dir, '..', '..')), { recursive: true }); + + if (!local) { + return rm(normalize(join(dir, '..', '..')), { recursive: true }); + } })); stdout.write(`\nMigrated ${fileCount} ${fileCount === 1 ? 'golden' : 'goldens'} found in ${dirs.length} test ${dirs.length === 1 ? 'directory' : 'directories'}\n`);