davidferguson / pibakery

The blocks based, easy to use setup tool for Raspberry Pi
http://www.PiBakery.org
GNU General Public License v3.0
1.49k stars 147 forks source link

Add Import Fix for Windows #5

Closed MTRNord closed 8 years ago

MTRNord commented 8 years ago

As mentioned in https://github.com/davidferguson/pibakery-blocks/issues/7 in windows the drag and drop did not work. Here is the fix for it.

lurch commented 8 years ago

I wonder if this could have been made neater, by doing e.g.

  var path_separator = '/'
  if (process.platform == 'win32') {
    path_separator == '\\'
  }
  var folderName = filepath.split(path_separator).slice(-1)[0]
  var jsonFile = path.normalize(filepath + path_separator + folderName + '.json')

? (with similar changes where you build the blocksFolder string)

MTRNord commented 8 years ago

As I now mentioned in the linked issue it could also be a good thing to use path.join() also codeclimate would give it than a better result maybe :D Doc Reference: https://nodejs.org/api/path.html#path_path_join_path I am testing this now on my Mashine. If it works I will tell here :)