makeLn.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. let exec = require('child_process').exec;
  2. let fs = require('fs');
  3. const executeShell = (command, callback) => {
  4. exec(command, (error, stdout, stderr) => {
  5. callback(stdout);
  6. });
  7. };
  8. executeShell('find * | grep index', out => {
  9. let fileList = out.split('\n');
  10. fileList = fileList.map(file => {
  11. return {
  12. component: file.split('/')[1] === 'icon' ? 'icons' : file.split('/')[1],
  13. filename: file.split('/')[2],
  14. path: '../../../content/' + file,
  15. };
  16. });
  17. const componentCodeList=fs.readdirSync('../packages/semi-ui');
  18. const componentCodeListLowerCase=componentCodeList.map(dirName=>dirName.toLowerCase());
  19. fileList.map(item => {
  20. const index=componentCodeListLowerCase.indexOf(item.component);
  21. let isExists = index!==-1;
  22. if (isExists) {
  23. let cmd = `ln -s -f ${item.path} ../packages/semi-ui/${componentCodeList[index]}/${item.filename}`;
  24. executeShell(cmd, res => {
  25. console.log(`exec ${cmd} ${res}`);
  26. });
  27. }
  28. });
  29. });