Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jan
kresus
Commits
54e449d0
Commit
54e449d0
authored
Aug 30, 2016
by
Benjamin Bouvier
Browse files
Check that no unused logos are present;
parent
78331cd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
scripts/check-logos.js
View file @
54e449d0
/* eslint no-process-exit: 0 */
import
*
as
path
from
'
path-extra
'
;
import
*
as
fs
from
'
fs
'
;
import
banks
from
'
../shared/banks.json
'
;
let
log
=
require
(
'
printit
'
)({
prefix
:
'
check-logos
'
});
...
...
@@ -12,19 +15,45 @@ let imagesDir = path.join(path.dirname(fs.realpathSync(__filename)),
'
images
'
,
'
banks
'
);
let
allLogoHere
=
true
;
let
missingLogo
=
false
;
for
(
let
bank
of
banks
)
{
try
{
let
imagePath
=
path
.
join
(
imagesDir
,
`
${
bank
.
uuid
}
.png`
);
fs
.
accessSync
(
imagePath
,
fs
.
F_OK
);
}
catch
(
e
)
{
log
.
error
(
`
${
bank
.
uuid
}
: there is no logo for this module/bank`
);
allLogoHere
=
false
;
log
.
error
(
`Missing logo for
${
bank
.
uuid
}
.`
);
missingLogo
=
true
;
}
}
if
(
missingLogo
)
{
log
.
error
(
'
At least one missing logo.
'
);
process
.
exit
(
1
);
}
let
imageFiles
=
[];
fs
.
readdirSync
(
imagesDir
).
forEach
(
child
=>
{
let
file
=
path
.
join
(
imagesDir
,
child
);
if
(
fs
.
statSync
(
file
).
isDirectory
())
{
log
.
error
(
"
The images dir shouldn't contain a directory!
"
);
process
.
exit
(
1
);
}
let
cleanName
=
child
.
replace
(
'
.png
'
,
''
);
imageFiles
.
push
(
cleanName
);
});
let
bankSet
=
new
Set
(
banks
.
map
(
bank
=>
bank
.
uuid
));
let
orphanImage
=
false
;
for
(
let
file
of
imageFiles
)
{
if
(
!
bankSet
.
has
(
file
))
{
log
.
error
(
`Superfluous logo in the logo directory:
${
file
}
.`
);
orphanImage
=
true
;
}
}
if
(
!
allLogoHere
)
{
if
(
orphanImage
)
{
log
.
error
(
'
At least one orphan image.
'
);
process
.
exit
(
1
);
}
...
...
static/images/banks/hellobank.png
deleted
100644 → 0
View file @
78331cd8
2.18 KB
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment