mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 22:23:07 +00:00
Implement os/windows.parseWmicDiskDriveGet()
This commit is contained in:
parent
9dbf3a21cf
commit
75ce68c789
@ -259,11 +259,24 @@
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul>
|
||||
<li class='letter'>w</li>
|
||||
<ul>
|
||||
<li>
|
||||
<a href='file/lib/resin/os/windows/windows.coffee.html'>
|
||||
windows.coffee
|
||||
</a>
|
||||
<small>
|
||||
(lib/resin/os/windows)
|
||||
</small>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -87,7 +87,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -83,7 +83,7 @@ Error: Invalid configuration file: /opt/resin.conf
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -70,7 +70,7 @@ Error: Invalid credentials
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -70,7 +70,7 @@ Error: Invalid key
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -83,7 +83,7 @@ Error: Invalid path: /tmp
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -83,7 +83,7 @@ Error: You don't have any applications
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -83,7 +83,7 @@ Error: Couldn't find application
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -392,7 +392,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -119,7 +119,7 @@ console.log(contents.remoteUrl)
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -169,7 +169,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -37,7 +37,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -186,7 +186,7 @@ console.log(devices)
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -94,7 +94,7 @@ resin.errors.handle(error, shouldExit)
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -105,7 +105,7 @@ console.log(object.dataPrefix) # /opt/resin
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -57,7 +57,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -348,7 +348,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -47,7 +47,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -326,7 +326,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -316,7 +316,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -154,7 +154,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -52,7 +52,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -156,7 +156,7 @@ console.log(result)
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
178
doc/file/lib/resin/os/windows/windows.coffee.html
Normal file
178
doc/file/lib/resin/os/windows/windows.coffee.html
Normal file
@ -0,0 +1,178 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<title>CoffeeScript API Documentation</title>
|
||||
<script src='../../../../../javascript/application.js'></script>
|
||||
<script src='../../../../../javascript/search.js'></script>
|
||||
<link rel='stylesheet' href='../../../../../stylesheets/application.css' type='text/css'>
|
||||
</head>
|
||||
<body>
|
||||
<div id='base' data-path='../../../../../'></div>
|
||||
<div id='header'>
|
||||
<div id='menu'>
|
||||
<a href='../../../../../alphabetical_index.html' title='Index'>
|
||||
Index
|
||||
</a>
|
||||
»
|
||||
<span class='title'>lib</span>
|
||||
»
|
||||
<span class='title'>resin</span>
|
||||
»
|
||||
<span class='title'>os</span>
|
||||
»
|
||||
<span class='title'>windows</span>
|
||||
»
|
||||
<span class='title'>windows.coffee</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id='content'>
|
||||
<h1>
|
||||
File:
|
||||
windows.coffee
|
||||
</h1>
|
||||
<table class='box'>
|
||||
<tr>
|
||||
<td>Defined in:</td>
|
||||
<td>lib/resin/os/windows</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Method Summary</h2>
|
||||
<ul class='summary'>
|
||||
<li>
|
||||
<span class='signature'>
|
||||
<a href='#parseWmicDiskDriveGet-'>
|
||||
~
|
||||
(Object)
|
||||
<b>parseWmicDiskDriveGet</b><span>(output)</span>
|
||||
</a>
|
||||
</span>
|
||||
<span class='note private title'>Private</span>
|
||||
<span class='desc'>
|
||||
Parse wmic diskdrive get output <pre><code>result = resin.os.windows.parseWmicDiskDriveGet(output)
|
||||
for item in result console.log("#{item.id} - #{item.caption}")
|
||||
</code></pre>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<h2>Method Details</h2>
|
||||
<div class='methods'>
|
||||
<div class='method_details'>
|
||||
<p class='signature' id='parseWmicDiskDriveGet-'>
|
||||
~
|
||||
(Object)
|
||||
<b>parseWmicDiskDriveGet</b><span>(output)</span>
|
||||
<span class='note private'>Private</span>
|
||||
<br>
|
||||
</p>
|
||||
<div class='docstring'>
|
||||
<div class='note'>
|
||||
<strong>Note:</strong>
|
||||
This only parses output from <code>wmic diskdrive get DeviceID, Caption</code>
|
||||
</div>
|
||||
<p>Parse wmic diskdrive get output</p><pre><code>result = resin.os.windows.parseWmicDiskDriveGet(output)
|
||||
for item in result console.log("#{item.id} - #{item.caption}")
|
||||
</code></pre>
|
||||
</div>
|
||||
<div class='tags'>
|
||||
<h3>Parameters:</h3>
|
||||
<ul class='param'>
|
||||
<li>
|
||||
<span class='name'>output</span>
|
||||
<span class='type'>
|
||||
(
|
||||
<tt>String</tt>
|
||||
)
|
||||
</span>
|
||||
—
|
||||
<span class='desc'>wmic diskdrive get DeviceID, Caption output </span>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Returns:</h3>
|
||||
<ul class='return'>
|
||||
<li>
|
||||
<span class='type'></span>
|
||||
(
|
||||
<tt>Object</tt>
|
||||
)
|
||||
—
|
||||
<span class='desc'>parsed result containing id and caption </span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
2.0.9
|
||||
✲
|
||||
Press H to see the keyboard shortcuts
|
||||
✲
|
||||
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
|
||||
✲
|
||||
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
|
||||
</div>
|
||||
<iframe id='search_frame'></iframe>
|
||||
<div id='fuzzySearch'>
|
||||
<input type='text'>
|
||||
<ol></ol>
|
||||
</div>
|
||||
<div id='help'>
|
||||
<p>
|
||||
Quickly fuzzy find classes, mixins, methods, file:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<span>T</span>
|
||||
Open fuzzy finder dialog
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
Control the navigation frame:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<span>L</span>
|
||||
Toggle list view
|
||||
</li>
|
||||
<li>
|
||||
<span>C</span>
|
||||
Show class list
|
||||
</li>
|
||||
<li>
|
||||
<span>I</span>
|
||||
Show mixin list
|
||||
</li>
|
||||
<li>
|
||||
<span>F</span>
|
||||
Show file list
|
||||
</li>
|
||||
<li>
|
||||
<span>M</span>
|
||||
Show method list
|
||||
</li>
|
||||
<li>
|
||||
<span>E</span>
|
||||
Show extras list
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
You can focus and blur the search input:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<span>S</span>
|
||||
Focus search input
|
||||
</li>
|
||||
<li>
|
||||
<span>Esc</span>
|
||||
Blur search input
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -227,7 +227,7 @@ resin.server.request { method: 'GET' url: '/download' p
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -77,7 +77,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -235,7 +235,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
December 09, 14 09:05:26 by
|
||||
December 09, 14 12:47:37 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -228,6 +228,22 @@
|
||||
lib/resin/os
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<span>
|
||||
windows
|
||||
</span>
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<a href='file/lib/resin/os/windows/windows.coffee.html' target='main'>
|
||||
windows.coffee
|
||||
</a>
|
||||
<small class='namespace'>
|
||||
lib/resin/os/windows
|
||||
</small>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
|
||||
<li>
|
||||
|
File diff suppressed because one or more lines are too long
@ -330,6 +330,14 @@
|
||||
(lib/resin/auth/auth.coffee)
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<a href='file/lib/resin/os/windows/windows.coffee.html#parseWmicDiskDriveGet-' target='main' title='parseWmicDiskDriveGet'>
|
||||
~parseWmicDiskDriveGet
|
||||
</a>
|
||||
<small>
|
||||
(lib/resin/os/windows/windows.coffee)
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<a href='file/lib/resin/helpers/helpers.coffee.html#prefixObjectValuesWithPath-' target='main' title='prefixObjectValuesWithPath'>
|
||||
~prefixObjectValuesWithPath
|
||||
@ -338,14 +346,6 @@
|
||||
(lib/resin/helpers/helpers.coffee)
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<a href='file/lib/resin/models/environment-variables.coffee.html#remove-' target='main' title='remove'>
|
||||
~remove
|
||||
</a>
|
||||
<small>
|
||||
(lib/resin/models/environment-variables.coffee)
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<a href='file/lib/resin/models/application.coffee.html#remove-' target='main' title='remove'>
|
||||
~remove
|
||||
@ -354,6 +354,14 @@
|
||||
(lib/resin/models/application.coffee)
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<a href='file/lib/resin/models/environment-variables.coffee.html#remove-' target='main' title='remove'>
|
||||
~remove
|
||||
</a>
|
||||
<small>
|
||||
(lib/resin/models/environment-variables.coffee)
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<a href='file/lib/resin/models/device.coffee.html#remove-' target='main' title='remove'>
|
||||
~remove
|
||||
|
@ -1,3 +1,5 @@
|
||||
exports.windows = require('./windows/windows')
|
||||
|
||||
# Generate os cache name
|
||||
#
|
||||
# It generates an unique name for a certain instance of the os
|
||||
|
@ -1,4 +1,5 @@
|
||||
_ = require('lodash')
|
||||
sinon = require('sinon')
|
||||
chai = require('chai')
|
||||
chai.use(require('chai-string'))
|
||||
expect = chai.expect
|
||||
|
44
lib/resin/os/windows/windows.coffee
Normal file
44
lib/resin/os/windows/windows.coffee
Normal file
@ -0,0 +1,44 @@
|
||||
_ = 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)
|
25
lib/resin/os/windows/windows.spec.coffee
Normal file
25
lib/resin/os/windows/windows.spec.coffee
Normal file
@ -0,0 +1,25 @@
|
||||
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…
Reference in New Issue
Block a user