Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

generatemklink.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // models\api\v1
  2. const fs = require('fs')
  3. var path = require('path');
  4. const { readdir } = require("fs").promises
  5. var verse = require('../serververse');
  6. const fswalk = verse.fs.walk
  7. var path = require('path');
  8. const Rx = require('rxjs');
  9. const cliargs = verse.cliargs;
  10. const processedArgs = cliargs(process.argv.slice(2));
  11. // console.dir(processedArgs)
  12. // console.dir(Rx)
  13. // https://github.com/coolaj86/node-walk
  14. // PB : TODO -- convert to an input json config.
  15. var outputfile = processedArgs._[0]; // ../elixir-client/physio/linkclient.bat
  16. var startdir = processedArgs._[1]; // ../elixir-client/physio-1/app/models/api/v1
  17. var inprefix = processedArgs._[2]; // '../../../../../elixir-client/client/'
  18. if(!inprefix) inprefix = '..\\client\\'
  19. var unprefix = processedArgs._[3]; // ../elixir-client/physio-1/
  20. if(!unprefix) unprefix = '../elixir-client/physio-1/'
  21. var outprefix = processedArgs._[4]; // '../../../../../elixir-client/physio/'
  22. if(!outprefix) outprefix = ''
  23. var fswalkoptions = {} // all files recurscively
  24. // var fswalkoptions = { includerootdir : true, includedirectories : true, expand : true } // example walk and output everything.
  25. // (unprefix, outprefix)
  26. // console.log(path.normalize(unprefix))
  27. const writeStream = ( fs.createWriteStream(outputfile) )
  28. fswalk.call( fswalkoptions, startdir ).then( s => {
  29. s.subscribe( entry => {
  30. // var matches = /.*?data.*/.exec(utils.fs.direntToFullname(entry))
  31. // if(matches) console.dir( matches[0] ) // Filters can be done on the stream itself..
  32. var i = entry
  33. var pathnodes = i.path.replace( path.normalize(unprefix), '' ).split('\\')
  34. var relative = Array(pathnodes.length)
  35. writeStream.write( '\nmklink ' + (entry.isDirectory() ? ' /D ' : ' ') + i.path.replace( path.normalize(unprefix), outprefix ) + ' '
  36. + relative.join('..\\') + inprefix + i.path.replace( path.normalize(unprefix), outprefix )
  37. )
  38. // console.dir( entry )
  39. }
  40. )
  41. // ; s.unsubscribe()
  42. })