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

'svgDir' can be an array ? #8

Open
alex-mm opened this issue Sep 28, 2016 · 1 comment
Open

'svgDir' can be an array ? #8

alex-mm opened this issue Sep 28, 2016 · 1 comment

Comments

@alex-mm
Copy link

alex-mm commented Sep 28, 2016

like this:

configureSvgIcon({
    destination: path.join(__dirname, 'src', 'Icon.js'),
    svgDir: [
        path.join(__dirname, 'src', 'svg'),
        path.join(__dirname, 'demo', src', 'svg')
    ],
});
@teameh
Copy link
Contributor

teameh commented Oct 5, 2016

Nice. I think something like this would work:

diff --git a/src/configureGenerator.js b/src/configureGenerator.js
index 24fb5e3..7c17391 100644
--- a/src/configureGenerator.js
+++ b/src/configureGenerator.js
@@ -18,16 +18,15 @@ export default function configureGenerator(config) {
       : path.join(process.cwd(), template);
     const templateContent = fs.readFileSync(templateFile).toString();

-    const svgDir = path.isAbsolute(config.svgDir)
-      ? config.svgDir
-      : path.join(process.cwd(), config.svgDir);
-
-    console.log('Looking for SVG Icons in:', svgDir); // eslint-disable-line no-console
+    const svgDirs = Array.isArray(config.svgDir) ? config.svgDir : [config.svgDir];
+    const svgs = svgDirs.reduce((result, d) => {
+      const svgDir = path.isAbsolute(d) ? d : path.join(process.cwd(), d);
+      console.log('Looking for SVG Icons in:', svgDir); // eslint-disable-line no-console
+      return [].concat(getSvsgInDir(svgDir));
+    }, []);

     console.log('Using Icon template from:', templateFile); // eslint-disable-line no-console

-    const svgs = getSvsgInDir(svgDir);
-
     const iconDestination = config.destination || path.join(process.cwd(), 'Icon.react.js');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants