drivelist
Advanced tools
Comparing version 9.1.0 to 9.2.0-include-partition-table-info-1ee43c2eb4543dec78aceca566e645dfc5b29a93
@@ -7,2 +7,9 @@ # Change Log | ||
# v9.2.0 | ||
## (2020-11-19) | ||
* Add partitionTableType field: 'gpt', 'mbr' or null (windows) [Alexis Svinartchouk] | ||
* Add partitionTableType field: 'gpt', 'mbr' or null (mac) [Alexis Svinartchouk] | ||
* Add partitionTableType field: 'gpt', 'mbr' or null (linux) [Alexis Svinartchouk] | ||
# v9.1.0 | ||
@@ -9,0 +16,0 @@ ## (2020-08-06) |
@@ -26,2 +26,3 @@ export interface Mountpoint { | ||
size: number | null; | ||
partitionTableType: 'mbr' | 'gpt' | null; | ||
} | ||
@@ -28,0 +29,0 @@ /** |
import { Drive } from '..'; | ||
export declare function getPartitionTableType(pttype?: 'gpt' | 'dos'): 'gpt' | 'mbr' | null; | ||
export declare function lsblk(): Promise<Drive[]>; |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lsblk = void 0; | ||
exports.lsblk = exports.getPartitionTableType = void 0; | ||
const child_process_1 = require("child_process"); | ||
@@ -29,2 +29,12 @@ const fs_1 = require("fs"); | ||
let SUPPORTS_JSON = true; | ||
function getPartitionTableType(pttype) { | ||
if (pttype === 'gpt') { | ||
return 'gpt'; | ||
} | ||
else if (pttype === 'dos') { | ||
return 'mbr'; | ||
} | ||
return null; | ||
} | ||
exports.getPartitionTableType = getPartitionTableType; | ||
async function getDevicePaths() { | ||
@@ -60,3 +70,3 @@ const mapping = new Map(); | ||
async function lsblkPairs() { | ||
return pairs_1.parse(await getOutput('lsblk', '--bytes', '--all', '--pairs')); | ||
return pairs_1.parse(await getOutput('lsblk', '--bytes', '--all', '--pairs', '-o', '+pttype')); | ||
} | ||
@@ -63,0 +73,0 @@ async function $lsblk() { |
@@ -22,2 +22,3 @@ import { Drive } from '..'; | ||
vendor: string | null; | ||
pttype?: 'gpt' | 'dos'; | ||
} | ||
@@ -24,0 +25,0 @@ interface LsblkJsonOutputDeviceChild { |
@@ -20,2 +20,3 @@ "use strict"; | ||
const path_1 = require("path"); | ||
const _1 = require("."); | ||
function getMountpoints(children) { | ||
@@ -105,2 +106,3 @@ return children | ||
isUAS: null, | ||
partitionTableType: _1.getPartitionTableType(device.pttype), | ||
}; | ||
@@ -107,0 +109,0 @@ }); |
"use strict"; | ||
/* | ||
* Copyright 2018 Balena.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parse = void 0; | ||
const _1 = require("."); | ||
function parseLsblkLine(line) { | ||
@@ -65,9 +81,10 @@ const data = {}; | ||
return primaries.map((device) => { | ||
const children = devices.filter((child) => { | ||
return (['disk', 'part'].includes(child.type) && | ||
child.name.startsWith(device.name) && | ||
child !== device); | ||
}); | ||
return Object.assign({}, device, { | ||
mountpoints: devices | ||
.filter((child) => { | ||
return (['disk', 'part'].includes(child.type) && | ||
child.mountpoint && | ||
child.name.startsWith(device.name)); | ||
}) | ||
mountpoints: children | ||
.filter((child) => child.mountpoint) | ||
.map((child) => { | ||
@@ -138,2 +155,3 @@ return { | ||
isUAS: null, | ||
partitionTableType: _1.getPartitionTableType(device.pttype), | ||
}; | ||
@@ -140,0 +158,0 @@ }); |
@@ -52,2 +52,3 @@ /* | ||
size: number | null; | ||
partitionTableType: 'mbr' | 'gpt' | null; | ||
} | ||
@@ -54,0 +55,0 @@ |
@@ -32,2 +32,11 @@ /* | ||
export function getPartitionTableType(pttype?: 'gpt' | 'dos'): 'gpt' | 'mbr' | null { | ||
if (pttype === 'gpt') { | ||
return 'gpt'; | ||
} else if (pttype === 'dos') { | ||
return 'mbr'; | ||
} | ||
return null; | ||
} | ||
async function getDevicePaths(): Promise<Map<string, string>> { | ||
@@ -75,3 +84,5 @@ const mapping = new Map(); | ||
async function lsblkPairs(): Promise<Drive[]> { | ||
return parsePairs(await getOutput('lsblk', '--bytes', '--all', '--pairs')); | ||
return parsePairs( | ||
await getOutput('lsblk', '--bytes', '--all', '--pairs', '-o', '+pttype'), | ||
); | ||
} | ||
@@ -78,0 +89,0 @@ |
@@ -19,2 +19,3 @@ /* | ||
import { getPartitionTableType } from '.'; | ||
import { Drive, Mountpoint } from '..'; | ||
@@ -43,2 +44,3 @@ | ||
vendor: string | null; | ||
pttype?: 'gpt' | 'dos'; | ||
} | ||
@@ -147,2 +149,3 @@ | ||
isUAS: null, | ||
partitionTableType: getPartitionTableType(device.pttype), | ||
}; | ||
@@ -149,0 +152,0 @@ }, |
@@ -16,2 +16,4 @@ /* | ||
*/ | ||
import { getPartitionTableType } from '.'; | ||
import { Drive, Mountpoint } from '..'; | ||
@@ -93,11 +95,12 @@ | ||
return primaries.map((device) => { | ||
const children = devices.filter((child) => { | ||
return ( | ||
['disk', 'part'].includes(child.type) && | ||
child.name.startsWith(device.name) && | ||
child !== device | ||
); | ||
}); | ||
return Object.assign({}, device, { | ||
mountpoints: devices | ||
.filter((child) => { | ||
return ( | ||
['disk', 'part'].includes(child.type) && | ||
child.mountpoint && | ||
child.name.startsWith(device.name) | ||
); | ||
}) | ||
mountpoints: children | ||
.filter((child) => child.mountpoint) | ||
.map( | ||
@@ -143,3 +146,7 @@ (child): Mountpoint => { | ||
return devices.map( | ||
(device: Dict<string> & { mountpoints: Mountpoint[] }): Drive => { | ||
( | ||
device: Dict<string> & { | ||
mountpoints: Mountpoint[]; | ||
}, | ||
): Drive => { | ||
const isVirtual = device.subsystems | ||
@@ -179,2 +186,3 @@ ? /^block$/i.test(device.subsystems) | ||
isUAS: null, | ||
partitionTableType: getPartitionTableType(device.pttype as 'gpt' | 'dos' | undefined), | ||
}; | ||
@@ -181,0 +189,0 @@ }, |
{ | ||
"name": "drivelist", | ||
"version": "9.1.0", | ||
"version": "9.2.0-include-partition-table-info-1ee43c2eb4543dec78aceca566e645dfc5b29a93", | ||
"description": "List all connected drives in your computer, in all major operating systems", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126239
1053
1