Skip to content

Commit

Permalink
make generate-rule async, tested it locally
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Feb 16, 2024
1 parent c545fe1 commit ce25da2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tools/generate-rule.ts
@@ -1,6 +1,6 @@
import path from 'path'

import fs from 'fs'
import fs from 'fs/promises'
import cp from 'child_process'
import prompts from 'prompts'
import dedent from 'ts-dedent'
Expand Down Expand Up @@ -59,7 +59,7 @@ const generateRule = async () => {
const docFile = path.resolve(__dirname, `../docs/rules/${ruleId}.md`)

logger.log(`creating lib/rules/${ruleId}.ts`)
fs.writeFileSync(
await fs.writeFile(
ruleFile,
dedent(`/**
* @fileoverview ${ruleDescription}
Expand Down Expand Up @@ -142,7 +142,7 @@ const generateRule = async () => {
)

logger.log(`creating tests/lib/rules/${ruleId}.test.ts`)
fs.writeFileSync(
await fs.writeFile(
testFile,
dedent(`/**
* @fileoverview ${ruleDescription}
Expand Down Expand Up @@ -182,7 +182,7 @@ const generateRule = async () => {
)

logger.log(`creating docs/rules/${ruleId}.md`)
fs.writeFileSync(
await fs.writeFile(
docFile,
dedent(`
# ${ruleId}
Expand Down Expand Up @@ -243,4 +243,7 @@ const generateRule = async () => {
logger.log(`❤️ Thanks for helping this plugin get better, ${authorName.split(' ')[0]}!`)
}

generateRule()
generateRule().catch((error) => {
logger.error('An error occurred while generating the rule:', error)
process.exit(1)
})

0 comments on commit ce25da2

Please sign in to comment.