Skip to content

Commit

Permalink
feat(docz-core): copy eslint config to .docz (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakannimer authored Nov 14, 2019
1 parent 62ff4f4 commit 661755b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
22 changes: 17 additions & 5 deletions core/docz-core/src/bundler/machine/services/create-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,22 @@ const copyAndModifyPkgJson = async (ctx: ServerMachineCtx) => {
await fs.outputJSON(movePath, newPkg, { spaces: 2 })
}

const writeEslintRc = async ({ isDoczRepo }: ServerMachineCtx) => {
if (!isDoczRepo) return
const filepath = path.join(paths.docz, '.eslintrc')
await fs.outputJSON(filepath, { extends: 'react-app' })
const writeEslintRc = async () => {
const possibleFilenames = [
'.eslintrc.js',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
'.eslintrc',
]
for (const filename of possibleFilenames) {
const filepath = path.join(paths.root, filename)
const dest = path.join(paths.docz, filename)
if (fs.pathExistsSync(filepath)) {
await fs.copy(filepath, dest)
return
}
}
}

const copyEslintIgnore = async () => {
Expand Down Expand Up @@ -108,7 +120,7 @@ export const createResources = async (ctx: ServerMachineCtx) => {
try {
copyDoczRc(ctx.args.config)
await copyAndModifyPkgJson(ctx)
await writeEslintRc(ctx)
await writeEslintRc()
await copyEslintIgnore()
await writeNotFound()
await writeGatsbyConfig(ctx)
Expand Down
12 changes: 8 additions & 4 deletions core/docz-core/src/bundler/machine/services/exec-dev-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ export const execDevCommand = async ({ args }: ServerMachineCtx) => {
// For monorepos that install dependencies higher in the fs tree
const repoRootPath = get(args, 'repoRootPath', await findRootPath())
const gatsbyPath = path.join(repoRootPath, 'node_modules/.bin/gatsby')
spawn(gatsbyPath, ['develop', '--host', `${args.host}`, '--port', `${args.port}`], {
stdio: 'inherit',
cwd: paths.docz,
})
spawn(
gatsbyPath,
['develop', '--host', `${args.host}`, '--port', `${args.port}`],
{
stdio: 'inherit',
cwd: paths.docz,
}
)
const url = `http://${args.host}:${args.port}`
console.log()
console.log('Building app')
Expand Down

0 comments on commit 661755b

Please sign in to comment.