-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
prettier.js
63 lines (62 loc) · 1.63 KB
/
prettier.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Chomp.addExtension('[email protected]:npm')
Chomp.registerTemplate(
'prettier',
function ({
name,
targets,
deps,
env,
templateOptions: {
files = false,
check = false,
write = true,
config = null,
loglevel = false,
noErrorOnUnmatchedPattern = false,
ignorePath = false,
autoInstall,
...invalid
},
}) {
if (Object.keys(invalid).length)
throw new Error(
`Invalid prettier template option "${
Object.keys(invalid)[0]
}", expected one of "files", "check", "write", "config", "no-error-on-unmatched-pattern" or "auto-install".`
)
return [
{
name,
targets,
deps: [...deps, ...(ENV.CHOMP_EJECT ? ['npm:install'] : ['node_modules/prettier'])],
watchInvalidation: 'skip-running',
invalidation: 'always',
env,
run: `prettier --cache --cache-strategy metadata --loglevel ${loglevel || 'log'}${
ignorePath ? ` --ignore-path ${ignorePath}` : ''
}${config ? ` --config ${config}` : ''}${
noErrorOnUnmatchedPattern ? ' --no-error-on-unmatched-pattern' : ''
}${check ? ' --check' : ''}${write ? ' --write' : ''} ${
files
? files
.split(' ')
.map(ex => `"${ex}"`)
.join(' ')
: '.'
}`,
},
...(ENV.CHOMP_EJECT
? []
: [
{
template: 'npm',
templateOptions: {
autoInstall,
packages: ['prettier'],
dev: true,
},
},
]),
]
}
)