Skip to content

Commit b193125

Browse files
committed
add check for missing primer-css dependencies
1 parent 34bac11 commit b193125

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

script/check-imports

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const parseImports = filename => {
1616
})
1717
}
1818

19+
const isPrimerModule = name => name.indexOf('primer-') === 0
20+
1921
globby('modules/primer-*')
2022
.then(paths => {
2123
return paths.reduce((modules, path) => {
@@ -44,7 +46,8 @@ globby('modules/primer-*')
4446

4547
modules.forEach(mod => {
4648
const deps = Object.keys(mod.dependencies)
47-
.filter(key => key.indexOf('primer-') === 0)
49+
.filter(isPrimerModule)
50+
4851
tasks.push(
4952
parseImports(`${mod.path}/index.scss`)
5053
.then(imports => {
@@ -66,6 +69,27 @@ globby('modules/primer-*')
6669
)
6770
})
6871
return Promise.all(tasks)
72+
.then(() => {
73+
const primer = map.get('primer-css')
74+
75+
const deps = new Set(
76+
Object.keys(primer.dependencies)
77+
.filter(isPrimerModule)
78+
.sort()
79+
)
80+
81+
modules
82+
.map(mod => mod.name)
83+
.filter(mod => mod !== primer.name)
84+
.sort()
85+
.forEach(mod => {
86+
if (!deps.has(mod)) {
87+
throw new Error(
88+
`primer-css is missing dependency for ${mod}@${map.get(mod).version}`
89+
)
90+
}
91+
})
92+
})
6993
.then(() => matches)
7094
})
7195
.catch(error => {

0 commit comments

Comments
 (0)