-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: read file path from regex-doctor config file
- Loading branch information
Showing
11 changed files
with
58 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import process from 'node:process' | ||
import { loadConfig } from 'c12' | ||
import type { RegexDoctorConfig } from './types' | ||
|
||
export function defineRegexDoctorConfig(config: RegexDoctorConfig) { | ||
return config | ||
} | ||
|
||
const defaultFileData: Required<RegexDoctorConfig> = { | ||
rootDir: '.', | ||
outputDir: '.regex-doctor', | ||
outputFileName: 'output.bin', | ||
} | ||
|
||
export async function loadRegexDoctorConfig() { | ||
const { config, cwd } = await loadConfig({ | ||
name: 'regex-doctor', | ||
configFile: 'regex-doctor.config', | ||
}) | ||
|
||
return { | ||
...defaultFileData, | ||
rootDir: cwd ?? process.cwd(), | ||
...config, | ||
} satisfies Required<RegexDoctorConfig> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
/* eslint-disable no-console */ | ||
import process from 'node:process' | ||
import exitHook from 'exit-hook' | ||
import { asyncExitHook } from 'exit-hook' | ||
import c from 'picocolors' | ||
import { RegexDoctor } from './doctor' | ||
|
||
console.log(`[regex-doctor] start tracking`) | ||
|
||
const doctor = new RegexDoctor() | ||
const cwd = process.cwd() | ||
doctor.start() | ||
|
||
exitHook(() => { | ||
asyncExitHook(async () => { | ||
doctor.stop() | ||
doctor.dump({ cwd }) | ||
console.log(`[regex-doctor] output saved to ${c.blue(RegexDoctor.filePath)}, run ${c.green(c.bold('npx regex-doctor view'))} to view it in an interactive UI.`) | ||
await doctor.dump() | ||
console.log(`[regex-doctor] output saved to ${c.blue(await RegexDoctor.getFilePath())}, run ${c.green(c.bold('npx regex-doctor view'))} to view it in an interactive UI.`) | ||
}, { | ||
wait: 10000, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface RegexDoctorConfig { | ||
rootDir?: string | ||
outputDir?: string | ||
outputFileName?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './data' | ||
export * from './options' | ||
export * from './record' | ||
export * from './config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { defineRegexDoctorConfig } from 'regex-doctor' | ||
|
||
export default defineRegexDoctorConfig({}) |