Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 661755b

Browse files
authored
feat(docz-core): copy eslint config to .docz (#1254)
1 parent 62ff4f4 commit 661755b

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

core/docz-core/src/bundler/machine/services/create-resources.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,22 @@ const copyAndModifyPkgJson = async (ctx: ServerMachineCtx) => {
4343
await fs.outputJSON(movePath, newPkg, { spaces: 2 })
4444
}
4545

46-
const writeEslintRc = async ({ isDoczRepo }: ServerMachineCtx) => {
47-
if (!isDoczRepo) return
48-
const filepath = path.join(paths.docz, '.eslintrc')
49-
await fs.outputJSON(filepath, { extends: 'react-app' })
46+
const writeEslintRc = async () => {
47+
const possibleFilenames = [
48+
'.eslintrc.js',
49+
'.eslintrc.yaml',
50+
'.eslintrc.yml',
51+
'.eslintrc.json',
52+
'.eslintrc',
53+
]
54+
for (const filename of possibleFilenames) {
55+
const filepath = path.join(paths.root, filename)
56+
const dest = path.join(paths.docz, filename)
57+
if (fs.pathExistsSync(filepath)) {
58+
await fs.copy(filepath, dest)
59+
return
60+
}
61+
}
5062
}
5163

5264
const copyEslintIgnore = async () => {
@@ -108,7 +120,7 @@ export const createResources = async (ctx: ServerMachineCtx) => {
108120
try {
109121
copyDoczRc(ctx.args.config)
110122
await copyAndModifyPkgJson(ctx)
111-
await writeEslintRc(ctx)
123+
await writeEslintRc()
112124
await copyEslintIgnore()
113125
await writeNotFound()
114126
await writeGatsbyConfig(ctx)

core/docz-core/src/bundler/machine/services/exec-dev-command.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ export const execDevCommand = async ({ args }: ServerMachineCtx) => {
3535
// For monorepos that install dependencies higher in the fs tree
3636
const repoRootPath = get(args, 'repoRootPath', await findRootPath())
3737
const gatsbyPath = path.join(repoRootPath, 'node_modules/.bin/gatsby')
38-
spawn(gatsbyPath, ['develop', '--host', `${args.host}`, '--port', `${args.port}`], {
39-
stdio: 'inherit',
40-
cwd: paths.docz,
41-
})
38+
spawn(
39+
gatsbyPath,
40+
['develop', '--host', `${args.host}`, '--port', `${args.port}`],
41+
{
42+
stdio: 'inherit',
43+
cwd: paths.docz,
44+
}
45+
)
4246
const url = `http://${args.host}:${args.port}`
4347
console.log()
4448
console.log('Building app')

0 commit comments

Comments
 (0)