-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxo-quick.js
More file actions
35 lines (28 loc) · 813 Bytes
/
xo-quick.js
File metadata and controls
35 lines (28 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
const path = require('path')
const { writeFileSync, existsSync, unlinkSync } = require('fs')
const sort = require('sort-package-json')
const xo = require('./package.json')
try {
const workDir = process.env.INIT_CWD
let modified = false
let target = path.join(workDir, 'package.json')
const pkg = require(target)
for (const tool of ['prettier', 'husky', 'xo']) {
if (typeof pkg[tool] === 'undefined') {
pkg[tool] = xo[tool]
modified = true
}
}
if (modified) {
writeFileSync(target, JSON.stringify(sort(pkg), null, '\t') + '\n', 'utf8')
}
for (const file of ['.prettierrc', 'prettier.config.js']) {
target = path.join(workDir, file)
if (existsSync(target)) {
unlinkSync(target)
}
}
} catch (error) {
console.error('xo-quick postinstall failed :', error)
}