-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprettier.dang
More file actions
48 lines (39 loc) · 1.03 KB
/
prettier.dang
File metadata and controls
48 lines (39 loc) · 1.03 KB
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
type Prettier {
"""
The source directory for the project.
"""
pub source: Directory! @defaultPath(path: "/")
"""
The base image to use.
"""
pub baseImageAddress: String! = "node:25-alpine"
"""
The package manager to use.
"""
pub packageManager: String! = "npm"
"""
Check that if the files are formatted.
"""
pub check: Void @check {
node(source, baseImageAddress, packageManager).base.
withExec(["npx", "prettier", "--check", "."]).
sync
null
}
"""
Rewrite all processed files in place.
"""
pub write: Changeset {
let fixFilter = ["**/*.js", "**/*.ts", "**/*.md", "**/*.jsx"]
let fixed = node(source, baseImageAddress, packageManager).base.
withExec(["npx", "prettier", "--write", "."]).
directory(".").
withoutDirectory("node_modules")
let fixedJs = directory.
withDirectory(".", fixed, include: fixFilter)
let sourceJs = directory.
withDirectory(".", source.withoutDirectory("node_modules"), include: fixFilter)
fixedJs.
changes(sourceJs)
}
}