fantasticon icon indicating copy to clipboard operation
fantasticon copied to clipboard

Create directories

Open nunos7 opened this issue 3 years ago • 7 comments

Hi, When I define pathOptions in the config file, and previously I don't create the directories it fail: ENOENT: no such file or directory, open '.........\dist\icons-regular\icons.ttf'

There are some parameters that I need to define to allow the creation of directories? Or I always need to create the directories before run fantasticon?

Thank you all NS

nunos7 avatar Mar 16 '21 10:03 nunos7

For now fantasticon expects the directories to exist - I'd rather have it fail then start creating directories recursively in your filesystem when you get some configuration wrong (just doesn't seem the safest option ;) ) make sense?

tancredi avatar Mar 16 '21 19:03 tancredi

Hello, I understand your point of view, but as it is about directories / files that are not versioned, I think that fantasticon could guarantee the cleaning / creation of the necessary directories / files in the outputDir directory (and pathOptions). In my case, I have a script that is reading my fantasticon configuration file, and ensuring that the directories are cleaned / created. If you understand that it can be an asset for fantasticon to have this option, tell me and I can make a pull request

nunos7 avatar Mar 17 '21 09:03 nunos7

I do understand that - I need to have a proper look at how other build tools do regarding this (it's usually a mixed bag) meanwhile I'll re-open the issue.

Meanwhile, rather than writing a Node.js script, could be cleaner to have a pre npm script with a bit of bash (that's how I usually prepare directories for build in my package.json)

For example:

{
  "scripts": {
    "preicons": "rm -rf dist && mkdir -p dist && mkdir -p dist/other",
    "icons": "fantasticon"
  }
}

This also ensures you clean the directory every time before the icons scripts runs.

Let me know your thoughts

tancredi avatar Mar 17 '21 09:03 tancredi

If it was just the outputDir directory, yes, I think as you say it is the simplest, but here the situation is really pathOptions, where we can put different paths, for example:


pathOptions: {      
	  ttf: './dist/icons-regular/font/icons.ttf',
      woff: './dist/icons-regular/font/icons.woff',
      woff2: './dist/icons-regular/font/icons.woff2',
      eot: './dist/icons-regular/font/icons.eot',
      svg: './dist/icons-regular/font/icons.svg',	  
      ts: './dist/icons-regular/types/icon-types.ts',    	  
      css: './dist/icons-regular/css/icons.css',
      scss: './dist/icons-regular/css/icons.scss',
      html: './dist/icons-regular/demo/index.html',  
    }

nunos7 avatar Mar 17 '21 12:03 nunos7

Any updates on this? Right now we solved this by adding .keep files, it'd be really nice if these directories would be created automatically :/

simonwep avatar Sep 14 '21 12:09 simonwep

"preicons": "rm -rf dist && mkdir -p dist && mkdir -p dist/other",

The issue with this is that it only works on those systems where rm -rf and mkdir -p exists :D - it's not only windows that will fail to run this. I think this is one of the reasons that many cli tools that write to disk abstract folder creation/deletion.

tgelu avatar Oct 18 '22 09:10 tgelu

And in addition i do not want my scss file in a public directory, where the fonts are held 🤔

dennis-f avatar May 12 '23 13:05 dennis-f