-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.js
More file actions
38 lines (34 loc) · 828 Bytes
/
Package.js
File metadata and controls
38 lines (34 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const Util = require('./Util')
class Package {
/**
* Get package path
* @param {String} name package name
* @return {String}
*/
static getPath(name) {
const packpath = Util.join(this.path, name)
const mainpath = Util.readJSON(Util.join(packpath, 'package.json')).main
return Util.join(packpath, mainpath)
}
/**
* Return package
* @param {String} name package name
* @return {BrowserWindow|Null}
*/
static getPackage(name) {
if (Util.isExist(this.getPath(name))) {
const Pack = require(this.getPath(name))
return new Pack()
} else
Util.showError(Util._('notExistPackage'))
}
/**
* Get packages folder path
* @return {String}
* @readonly
*/
static get path() {
return Util.join(__dirname, 'packages')
}
}
module.exports = Package