You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
829 B

6 days ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /**
  2. * Generate import line for style.scss
  3. */
  4. const fs = require('fs')
  5. const path = require('path')
  6. const partials = path.join(__dirname, './partials')
  7. const generateImport = (dirname, filename) => {
  8. filename = filename.replace('_', '').replace('.scss', '');
  9. const line = '@import \'partials/' + dirname + filename + '\';';
  10. console.log(line);
  11. }
  12. const files = fs.readdirSync(partials)
  13. for (let filename of files) {
  14. const filepath = path.join(partials, filename)
  15. if (fs.lstatSync(filepath).isDirectory()) {
  16. const dirpath = filepath
  17. const files = fs.readdirSync(dirpath);
  18. for (let filename of files) {
  19. const filepath = path.join(dirpath, filename);
  20. generateImport(path.basename(dirpath) + '/', path.basename(filepath));
  21. }
  22. } else {
  23. generateImport('', path.basename(filepath));
  24. }
  25. }