initial
This commit is contained in:
4
ts/index.ts
Normal file
4
ts/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import * as plugins from './smartdrive.plugins'
|
||||
|
||||
export * from './smartdrive.classes.localdrivelist'
|
||||
export * from './smartdrive.interfaces'
|
20
ts/smartdrive.classes.localdrivelist.ts
Normal file
20
ts/smartdrive.classes.localdrivelist.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import * as plugins from './smartdrive.plugins'
|
||||
import { IDrive } from './smartdrive.interfaces'
|
||||
|
||||
let promisifiedDrivelist = plugins.smartq.promisify<any>(plugins.drivelist.list)
|
||||
|
||||
export class LocalDriveList {
|
||||
private _list: IDrive[] = null
|
||||
|
||||
async getList (): Promise<IDrive[]> {
|
||||
if (!this._list) {
|
||||
this._list = await promisifiedDrivelist()
|
||||
}
|
||||
return this._list
|
||||
}
|
||||
|
||||
async getUpdatedList (): Promise<IDrive[]> {
|
||||
this._list = null
|
||||
return await this.getList()
|
||||
}
|
||||
}
|
15
ts/smartdrive.interfaces.ts
Normal file
15
ts/smartdrive.interfaces.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import * as plugins from './smartdrive.plugins'
|
||||
|
||||
export interface IDrive {
|
||||
device: string
|
||||
description: string
|
||||
size: number,
|
||||
mountpoints: IMountpoint[]
|
||||
raw: string
|
||||
protected: boolean
|
||||
system: boolean
|
||||
}
|
||||
|
||||
export interface IMountpoint {
|
||||
path: string
|
||||
}
|
8
ts/smartdrive.plugins.ts
Normal file
8
ts/smartdrive.plugins.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import 'typings-global'
|
||||
import * as drivelist from 'drivelist'
|
||||
import * as smartq from 'smartq'
|
||||
|
||||
export {
|
||||
drivelist,
|
||||
smartq
|
||||
}
|
Reference in New Issue
Block a user