mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-21 09:30:56 +00:00
Document resin/helpers
This commit is contained in:
parent
88ecade342
commit
6b3042760e
@ -1,9 +1,36 @@
|
||||
_ = require('lodash')
|
||||
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
|
||||
#
|
||||
# @param {String} prefix path prefix
|
||||
# @param {Object} object object containing relative paths as values
|
||||
#
|
||||
# @note Absolute values will be omitted
|
||||
#
|
||||
# @example Prefix object with path
|
||||
# object =
|
||||
# dataPrefix: 'resin'
|
||||
#
|
||||
# object = prefixObjectValuesWithPath('/opt', object)
|
||||
# console.log(object.dataPrefix) # /opt/resin
|
||||
#
|
||||
exports.prefixObjectValuesWithPath = (prefix, object) ->
|
||||
return _.object _.map object, (value, key) ->
|
||||
result = [ key ]
|
||||
|
Loading…
x
Reference in New Issue
Block a user