mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-16 10:24:12 +03:00
8431fd9683
* Accept icon rather than title in `iconToSlug` This removes the need in (most of the) calls to this function to seperately check if there is a custom slug already defined for the icon. * Rename `titleToSlug` to `getIconSlug` * Revert unnecessary style change * Update function documentation * Keep `titleToSlug` and add `getIconSlug` helper Unfortunately `this` is not available because we're using arrow syntax for these functions, but refering to `titleToSlug` through `module.exports` works fine as well. * Fix parameter name in `getIconSlug` docs
20 lines
546 B
JavaScript
20 lines
546 B
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* @fileoverview
|
|
* Script that takes a brand name as argument and outputs the corresponding
|
|
* icon SVG filename to standard output.
|
|
*/
|
|
|
|
const { titleToSlug } = require("./utils.js");
|
|
|
|
if (process.argv.length < 3) {
|
|
console.error("Provide a brand name as argument");
|
|
process.exit(1);
|
|
} else {
|
|
const brandName = process.argv.slice(3)
|
|
.reduce((acc, arg) => `${acc} ${arg}`, process.argv[2]);
|
|
|
|
const filename = titleToSlug(brandName);
|
|
console.log(`For '${brandName}' use the file 'icons/${filename}.svg'`);
|
|
}
|