Skip to content

Commit

Permalink
Remove micromatch, use regex instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lelinhtinh committed Jan 11, 2025
1 parent 5da84ef commit 74d065e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from 'node:fs'
import path from 'node:path'
import chalk from 'chalk'
import inquirer from 'inquirer'
import mm from 'micromatch'
import mongoose from 'mongoose'

import { getMigrationModel } from './model'
Expand Down Expand Up @@ -364,9 +363,9 @@ class Migrator {
const files = fs.readdirSync(this.migrationsPath)
const migrationsInDb = await this.migrationModel.find({}).exec()

const fileExtensionGlobs = ['*.js', '**/!(*.d).ts'] // allow .js and .ts files, but not .d.ts files
const fileExtensionMatch = /(\.js|(?<!\.d)\.ts)$/ // allow .js and .ts files, but not .d.ts files
const migrationsInFs = files
.filter((filename) => /^\d{13,}-/.test(filename) && mm.isMatch(filename, fileExtensionGlobs))
.filter((filename) => /^\d{13,}-/.test(filename) && fileExtensionMatch.test(filename))
.map((filename) => {
const filenameWithoutExtension = filename.replace(/\.(js|ts)$/, '')
const [time] = filename.split('-')
Expand Down

0 comments on commit 74d065e

Please sign in to comment.