Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional input and output directory arguments to scripts/generate-icons.js #1064

Merged
merged 2 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage/
# Use Yarn rather than npm to manage the lockfile.
package-lock.json

.eslintcache
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
"build": "yarn build-lib && tsc --build src/tsconfig.json",
"build-pattern-lib": "yarn gulp bundle-css && yarn rollup -c rollup.config.js",
"typecheck": "tsc --build src/tsconfig.json",
"lint": "eslint .",
"checkformatting": "prettier --check '**/*.{js,scss,ts,tsx,md}'",
"format": "prettier --list-different --write '**/*.{js,scss,ts,tsx,md}'",
"lint": "eslint --cache .",
"checkformatting": "prettier --cache --check '**/*.{js,scss,ts,tsx,md}'",
"format": "prettier --cache --list-different --write '**/*.{js,scss,ts,tsx,md}'",
"test": "gulp test",
"plop": "plop",
"push": "yarn build && yalc push"
Expand Down
14 changes: 12 additions & 2 deletions scripts/generate-icons.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-env node */

/* eslint-disable no-console */
import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
import * as path from 'node:path';
import { format } from 'prettier';
Expand Down Expand Up @@ -118,8 +121,15 @@ function generateIconIndex(componentDir) {
writeFileSync(outputFile, outputSrc);
}

const inputDir = 'images/icons';
const outputDir = 'src/components/icons';
const argv = process.argv;

if (argv.includes('--help')) {
console.log(`Usage: ${path.basename(argv[1])} [input_dir] [output_dir]`);
process.exit(0);
}

const inputDir = argv[2] ?? 'images/icons';
const outputDir = argv[3] ?? 'src/components/icons';

const svgFiles = readdirSync(inputDir).filter(file => file.endsWith('.svg'));
for (let file of svgFiles) {
Expand Down