-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorph-all-views.js
More file actions
51 lines (49 loc) · 1.09 KB
/
morph-all-views.js
File metadata and controls
51 lines (49 loc) · 1.09 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
49
50
51
import getViewIndex from './get-view-index.js'
import maybeMorph from './maybe-morph.js'
import path from 'path'
export default function morphAllViews({
as,
getFontImport,
getSystemImport,
filesView,
profile,
src,
tools,
viewsById,
viewsToFiles,
designSystemImportRoot,
}) {
return [...filesView]
.map((file) => viewsToFiles.get(file))
.filter((view) => !view.custom)
.map((view) => {
let { content, extraFiles = [] } = maybeMorph({
as,
getFontImport,
getSystemImport,
profile,
src,
tools,
verbose: false,
view,
viewsById,
viewsToFiles,
designSystemImportRoot,
})
return [
{
file: path.join(path.dirname(view.file), 'view.js'),
content,
},
...extraFiles.map(({ name, content }) => ({
file: path.join(path.dirname(view.file), name),
content,
})),
{
file: path.join(path.dirname(view.file), 'index.js'),
content: getViewIndex(view),
},
]
})
.flat()
}