-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathpackage.js
31 lines (26 loc) · 888 Bytes
/
package.js
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
'use strict';
class Package {
constructor(name, versionSpecified, versionInstalled, path) {
this.name = name;
this.path = path;
this.versionSpecified = versionSpecified;
this.versionInstalled = versionInstalled;
try {
this.needsUpdate = this.updateRequired();
this.isSymlinked = this.symlinked();
} catch(e) {
const versionText = '(version specified: ' + versionSpecified + ', version installed: ' + versionInstalled + '): ';
e.message = 'Failed processing module "' + name + '" ' + versionText + e.message;
throw e;
}
}
updateRequired() {
const VersionChecker = require('./version-checker');
return !VersionChecker.satisfies(this.versionSpecified, this.versionInstalled);
}
symlinked() {
const isSymlink = require('./utils/is-symlink');
return isSymlink(this.path);
}
}
module.exports = Package;