Skip to content

Commit

Permalink
chore: renamed regex variable
Browse files Browse the repository at this point in the history
  • Loading branch information
MathurAditya724 committed Jul 12, 2024
1 parent 0e1edb2 commit 9b4e0d3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/hooks/after-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ afterCreateHook.addHook(
},
)

const regex = /compatibility_date\s*=\s*"\d{4}-\d{2}-\d{2}"/
const compatibilityDateRegex = /compatibility_date\s*=\s*"\d{4}-\d{2}-\d{2}"/
afterCreateHook.addHook(['cloudflare-workers'], ({ directoryPath }) => {
const wranglerPath = path.join(directoryPath, 'wrangler.toml')
const wrangler = readFileSync(wranglerPath, 'utf-8')

const currentDate = new Date().toISOString().split('T')[0] // Get current date in YYYY-MM-DD format

// Get current date in YYYY-MM-DD format
const currentDate = new Date().toISOString().split('T')[0]
const rewritten = wrangler.replace(
regex,
compatibilityDateRegex,
`compatibility_date = "${currentDate}"`,
)

writeFileSync(wranglerPath, rewritten)
})

Expand Down

0 comments on commit 9b4e0d3

Please sign in to comment.