mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: escape regular expressions
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { escapeRegularExpression } from '@/utils/helpers/string';
|
||||
|
||||
// Get the argument passed (e.g., "all-users-fr")
|
||||
const arg: string | undefined = process.argv[2];
|
||||
|
||||
@@ -25,7 +27,8 @@ const templatePath: string = path.join(__dirname, '../config/template.ts');
|
||||
|
||||
// Check if a migration with the same name (excluding timestamp) already exists
|
||||
const migrationExists: boolean = fs.readdirSync(migrationsDir).some((file) => {
|
||||
const regex = new RegExp(`^[0-9]+-${arg}\.ts$`);
|
||||
const escapedRegExp = escapeRegularExpression(arg);
|
||||
const regex = new RegExp(`^[0-9]+-${escapedRegExp}\.ts$`);
|
||||
return regex.test(file);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user