Skip to content

Commit

Permalink
feat: write .eslintrc.js on init command
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Aug 30, 2017
1 parent c03020c commit e35110d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,19 @@ async function copyEditorConfig(baseDir) {
process.stdout.write(`${target} was updated.\n`)
}

async function writeESLintConfig(baseDir) {
const target = path.join(baseDir, '.eslintrc.js')
await fs.writeFile(target, `module.exports = {
root: true,
extends: ['ybiquitous'],
}
`)

process.stdout.write(`${target} was updated.\n`)
}

module.exports = async function init(baseDir = process.cwd()) {
await updatePackageFile(baseDir)

await copyEditorConfig(baseDir)
await writeESLintConfig(baseDir)
}
17 changes: 14 additions & 3 deletions src/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,22 @@ suite('init', () => {
})
})

test('write .editorconfig', async () => {
test('copy .editorconfig', async () => {
await init(workDir)

const original = await fs.readFile(path.join(__dirname, '..', '.editorconfig'), 'utf8')
const wrote = await fs.readFile(path.join(workDir, '.editorconfig'), 'utf8')
assert(original === wrote)
const copy = await fs.readFile(path.join(workDir, '.editorconfig'), 'utf8')
assert(original === copy)
})

test('write .eslintrc.js', async () => {
await init(workDir)

const wrote = await fs.readFile(path.join(workDir, '.eslintrc.js'), 'utf8')
assert(wrote === `module.exports = {
root: true,
extends: ['ybiquitous'],
}
`)
})
})

0 comments on commit e35110d

Please sign in to comment.