mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 17:33:18 +00:00
Remove helpers.isAbsolutePath() in favor of fsPlus.isAbsolute()
This commit is contained in:
parent
5059bcb212
commit
b4a49113fb
@ -1,20 +1,7 @@
|
||||
_ = require('lodash')
|
||||
fsPlus = require('fs-plus')
|
||||
path = require('path')
|
||||
|
||||
# Check is path is absolute
|
||||
#
|
||||
# @private
|
||||
#
|
||||
# @param {String} path path
|
||||
# @return {Boolean} is absolute
|
||||
#
|
||||
# @example Is path absolute?
|
||||
# console.log isAbsolutePath('/usr') # True
|
||||
# console.log isAbsolutePath('../Music') # False
|
||||
#
|
||||
exports.isAbsolutePath = (p) ->
|
||||
return path.resolve(p) is p
|
||||
|
||||
# Prefix relative value paths with another path
|
||||
#
|
||||
# @private
|
||||
@ -35,7 +22,7 @@ exports.prefixObjectValuesWithPath = (prefix, object) ->
|
||||
return _.object _.map object, (value, key) ->
|
||||
result = [ key ]
|
||||
|
||||
if exports.isAbsolutePath(value)
|
||||
if fsPlus.isAbsolute(value)
|
||||
result.push(value)
|
||||
else
|
||||
result.push(path.join(prefix, value))
|
||||
|
@ -5,24 +5,6 @@ helpers = require('./helpers')
|
||||
|
||||
describe 'Helpers:', ->
|
||||
|
||||
describe '#isAbsolutePath()', ->
|
||||
|
||||
it 'should return true for absolute paths', ->
|
||||
for path in [
|
||||
'/'
|
||||
'/Users/me'
|
||||
'/usr/share'
|
||||
]
|
||||
expect(helpers.isAbsolutePath(path)).to.be.true
|
||||
|
||||
it 'should return false for relative paths', ->
|
||||
for path in [
|
||||
'./hello'
|
||||
'../../resin'
|
||||
'directory/'
|
||||
]
|
||||
expect(helpers.isAbsolutePath(path)).to.be.false
|
||||
|
||||
describe '#prefixObjectWithPath()', ->
|
||||
|
||||
it 'should add the path to every value', ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user