mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
Make data module return undefined if key is not found
This commit is contained in:
parent
14bacbc4a4
commit
15620145eb
@ -20,8 +20,12 @@ constructPath = (key) ->
|
||||
return result
|
||||
|
||||
exports.get = haltIfNoPrefix (key, options, callback) ->
|
||||
keyPath = constructPath(key)
|
||||
fs.readFile(keyPath, options, callback)
|
||||
exports.has key, (hasKey) ->
|
||||
if not hasKey
|
||||
return callback?(null)
|
||||
|
||||
keyPath = constructPath(key)
|
||||
fs.readFile(keyPath, options, callback)
|
||||
|
||||
exports.set = haltIfNoPrefix (key, value, options, callback) ->
|
||||
keyPath = constructPath(key)
|
||||
|
@ -97,6 +97,12 @@ describe 'Data:', ->
|
||||
expect(value).to.not.exist
|
||||
done()
|
||||
|
||||
it 'should return undefined if key doesn\'t exists', (done) ->
|
||||
data.get 'nontexistantkey', encoding: 'utf8', (error, value) ->
|
||||
expect(error).to.not.exist
|
||||
expect(value).to.be.undefined
|
||||
done()
|
||||
|
||||
describe '#has()', ->
|
||||
|
||||
it 'should return true if a file exists', (done) ->
|
||||
|
Loading…
Reference in New Issue
Block a user