mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-03-22 12:05:20 +00:00
Remove os/windows module for now
This commit is contained in:
parent
c4422a171c
commit
8c6db6608d
@ -1,5 +1,3 @@
|
||||
exports.windows = require('./windows/windows')
|
||||
|
||||
# Generate os cache name
|
||||
#
|
||||
# It generates an unique name for a certain instance of the os
|
||||
|
@ -1,44 +0,0 @@
|
||||
_ = require('lodash')
|
||||
_.str = require('underscore.string')
|
||||
|
||||
# @nodoc
|
||||
trimString = (string) ->
|
||||
return string.trim()
|
||||
|
||||
# @nodoc
|
||||
unwords = (array) ->
|
||||
return _.str.join(' ', array...)
|
||||
|
||||
# @nodoc
|
||||
parseWmicDiskDrive = (item) ->
|
||||
result = _.str.clean(item)
|
||||
result = _.str.words(result)
|
||||
|
||||
caption = _.initial(result)
|
||||
caption = unwords(caption)
|
||||
|
||||
id = _.last(result)
|
||||
|
||||
return { caption, id }
|
||||
|
||||
# Parse wmic diskdrive get output
|
||||
#
|
||||
# @private
|
||||
#
|
||||
# @param {String} output wmic diskdrive get DeviceID, Caption output
|
||||
#
|
||||
# @return {Object} parsed result containing id and caption
|
||||
#
|
||||
# @note This only parses output from `wmic diskdrive get DeviceID, Caption`
|
||||
#
|
||||
# @example Parse wmic output
|
||||
# result = resin.os.windows.parseWmicDiskDriveGet(output)
|
||||
# for item in result
|
||||
# console.log("#{item.id} - #{item.caption}")
|
||||
#
|
||||
exports.parseWmicDiskDriveGet = (output) ->
|
||||
output = _.str.lines(output)
|
||||
output = _.map(output, trimString)
|
||||
output = _.reject(output, _.isEmpty)
|
||||
output = _.tail(output)
|
||||
return _.map(output, parseWmicDiskDrive)
|
@ -1,25 +0,0 @@
|
||||
fs = require('fs')
|
||||
chai = require('chai')
|
||||
expect = chai.expect
|
||||
windows = require('./windows')
|
||||
|
||||
describe 'OS Windows:', ->
|
||||
|
||||
describe '#parseWmicDiskDriveGet()', ->
|
||||
|
||||
beforeEach ->
|
||||
@wmicOutput = [
|
||||
'Caption DeviceID \r\r'
|
||||
'WDC WD10JPVX-75JC3T0 \\\\.\\PHYSICALDRIVE0 \r\r'
|
||||
'Generic STORAGE DEVICE USB Device \\\\.\\PHYSICALDRIVE1 \r\r'
|
||||
'\r\r'
|
||||
''
|
||||
].join('\n')
|
||||
|
||||
it 'should parse the output', ->
|
||||
result = windows.parseWmicDiskDriveGet(@wmicOutput)
|
||||
|
||||
expect(result).to.deep.equal [
|
||||
{ caption: 'WDC WD10JPVX-75JC3T0', id: '\\\\.\\PHYSICALDRIVE0' }
|
||||
{ caption: 'Generic STORAGE DEVICE USB Device', id: '\\\\.\\PHYSICALDRIVE1' }
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user