Skip to content

Commit

Permalink
Separator patch
Browse files Browse the repository at this point in the history
  • Loading branch information
StaticRocket committed Jan 5, 2019
1 parent 5687a05 commit 90c8333
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
10 changes: 5 additions & 5 deletions lib/arduino-upload.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ path = require 'path'
OutputView = require './output-view'
SerialView = require './serial-view'
tmp = require 'tmp'
{ seperator, getArduinoPath } = require './util'
{ separator, getArduinoPath } = require './util'
Boards = require './boards'

try
Expand Down Expand Up @@ -146,14 +146,14 @@ module.exports = ArduinoUpload =
return options
isArduinoProject: () ->
editor = atom.workspace.getActivePaneItem()
file = editor?.buffer?.file?.getPath()?.split seperator
file = editor?.buffer?.file?.getPath()?.split separator
file?.pop()
name = file?.pop()
file?.push name
workpath = file?.join seperator
workpath = file?.join separator
name += '.ino'
file?.push name
file = file?.join seperator
file = file?.join separator
isArduino = fs.existsSync file
return {isArduino, workpath, file, name}
_build: (options, callback, onerror, port = false) ->
Expand Down Expand Up @@ -221,7 +221,7 @@ module.exports = ArduinoUpload =
atom.notifications.addError 'Build failed!'
else if keep
for ending in ['.eep', '.elf', '.hex', '.bin']
fs.createReadStream(info.buildFolder + info.name + ending).pipe(fs.createWriteStream(info.workpath + seperator + info.name + ending))
fs.createReadStream(info.buildFolder + separator + info.name + ending).pipe(fs.createWriteStream(info.workpath + separator + info.name + ending))

upload: ->
@getPort (port) =>
Expand Down
38 changes: 19 additions & 19 deletions lib/boards.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ fs = require 'fs'

readdir = Promise.promisify(fs.readdir)
readFile = Promise.promisify(fs.readFile)
{ seperator, getArduinoPath } = require './util'
module.exports =
{ separator, getArduinoPath } = require './util'
module.exports =
class Boards extends SelectListView
inited: false
loaded: false
Expand Down Expand Up @@ -39,14 +39,14 @@ module.exports =
parseNewPath: (path) ->
return readdir(path).then((files) =>
Promise.each(files, (pkg) =>
path2 = path + seperator + pkg + seperator + 'hardware'
path2 = path + separator + pkg + separator + 'hardware'
readdir(path2).then((files) =>
Promise.each(files, (arch) =>
path3 = path2 + seperator + arch
path3 = path2 + separator + arch
readdir(path3).then((files) =>
Promise.each(files, (version) =>
path4 = path3 + seperator + version
return @addBoards pkg, arch, path4 + seperator + 'boards.txt'
path4 = path3 + separator + version
return @addBoards pkg, arch, path4 + separator + 'boards.txt'
)
).catch((err) =>
# do nothing
Expand All @@ -62,12 +62,12 @@ module.exports =
parseOldPath: (path) ->
return readdir(path).then((files) =>
Promise.each(files, (pkg) =>
path2 = path + seperator + pkg
path2 = path + separator + pkg
readdir(path2).then((files) =>
Promise.each(files, (arch) =>
return @addBoards pkg, arch, path2 + seperator + arch + seperator + 'boards.txt'
return @addBoards pkg, arch, path2 + separator + arch + separator + 'boards.txt'
)
).catch((err) =>
).catch((err) =>
# do nothing
)
)
Expand All @@ -81,17 +81,17 @@ module.exports =
# first we parse the arduino15 file structure
path = ''
if /^win/.test process.platform
path = process.env.LOCALAPPDATA + seperator + 'Arduino15'
path = process.env.LOCALAPPDATA + separator + 'Arduino15'
else if process.platform == 'darwin'
path = process.env.HOME + seperator + 'Arduino15'
path = process.env.HOME + separator + 'Arduino15'
else
path = process.env.HOME + seperator + '.arduino15'
path += seperator + 'packages'
path = process.env.HOME + separator + '.arduino15'
path += separator + 'packages'
@parseNewPath(path).then( =>
if /^win/.test process.platform
path = getArduinoPath().split(seperator)
path = getArduinoPath().split(separator)
path.pop()
path = path.join(seperator) + seperator + 'hardware'
path = path.join(separator) + separator + 'hardware'
return @parseOldPath(path)
).then( =>
# parse the pre-arduino 1.5 boards
Expand All @@ -109,8 +109,8 @@ module.exports =
res.pop()
res = res[res.length - 1]
resolve res
).then((path) =>
path = path.strip() + seperator + 'hardware'
).then((path) =>
path = path.strip() + separator + 'hardware'
@parseOldPath(path)
)
).finally( =>
Expand All @@ -128,7 +128,7 @@ module.exports =
populateStatusBar: ->
@div.innerHTML = ''
@selectNode = document.createElement 'select'

op = new Option()
op.value = ''
op.text = '== Arduino Setting =='
Expand All @@ -143,7 +143,7 @@ module.exports =
op.text = @boards[board]
@selectNode.options.add op
@div.appendChild @selectNode

cfg = atom.config.get 'arduino-upload.board'
if @boards[cfg] || cfg == ''
@selectNode.value = cfg
Expand Down
30 changes: 15 additions & 15 deletions lib/output-view.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{View} = require 'atom-space-pen-views'
escape = (s) ->
escape = (s) ->
s.replace(/&/g,'&amp;' ).replace(/</g,'&lt;').replace(/"/g,'&quot;').replace(/'/g,'&#039;')

{ seperator } = require './util'
{ separator } = require './util'

module.exports =
module.exports =
class OutputView extends View
message: ''

@content: ->
@div class: 'arduino-upload info-view', =>
@button click: 'close', class: 'btn', 'close'
Expand All @@ -18,7 +18,7 @@ module.exports =
if tmppath && path
line = line.replace /((?:\/|\n|^)[\w\-\/\.]+:)(\d)*/gi, (match) =>
# ok here we parse whcih filenames are clickable

# extra holds the additional path in front, whch isn't clickable (such as the sketch path, or the tmp path)
extra = ''
# line holds the line number to jump to
Expand All @@ -27,28 +27,28 @@ module.exports =
if !match.endsWith ':'
line = match.substring match.lastIndexOf(':')+1
match = match.substring 0, match.lastIndexOf(':') # we need this anyways to strip the last char

# check if it is in the tmp directory. stripping that from the link
if match.strip().startsWith tmppath
extra += tmppath
match = match.substring tmppath.length
# strip optional trailing seperator
if match[0] == seperator
extra += seperator
# strip optional trailing separator
if match[0] == separator
extra += separator
match = match.substring 1
# make sure that we are in the sketch folder
if match.strip().substring(0, 7) == 'sketch' + seperator
extra += 'sketch' + seperator
if match.strip().substring(0, 7) == 'sketch' + separator
extra += 'sketch' + separator
match = match.substring 7

# generate nice output
file = match
match += ':'
if line != -1
match += line
file = file.strip()
if seperator != file.substring 0,1
file = path + seperator + file
if separator != file.substring 0,1
file = path + separator + file
if file.lastIndexOf('.')==-1 || file.lastIndexOf('.')+20 < file.length
file += '.ino'
extra+'<a data-line="'+line+'" data-file="'+escape(file)+'">'+match+'</a>'
Expand All @@ -62,7 +62,7 @@ module.exports =
@hide()
return
@find('pre').html @message

for elem in @find('pre a')
elem.addEventListener 'click', ->
for pane in atom.workspace.getPanes()
Expand Down
6 changes: 3 additions & 3 deletions lib/util.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@seperator = '/'
@separator = '/'
if /^win/.test process.platform
@seperator = '\\'
@separator = '\\'

@getArduinoPath = () =>
@getArduinoPath = () =>
execPath = atom.config.get 'arduino-upload.arduinoExecutablePath'
if execPath == 'arduino'
# we want the default path which is actually dependent on our os
Expand Down

0 comments on commit 90c8333

Please sign in to comment.