pinokiod 7.1.21 → 7.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,10 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
+ const semver = require('semver')
3
4
 
4
5
  class Bluefairy {
5
6
  description = "Installs Bluefairy, a standalone package freshness guard."
7
+ version = ">=0.0.3"
6
8
 
7
9
  packageName() {
8
10
  return "bluefairy"
@@ -21,6 +23,16 @@ class Bluefairy {
21
23
  : this.kernel.path("bin/npm/bin")
22
24
  }
23
25
 
26
+ moduleRoot() {
27
+ return this.kernel.platform === "win32"
28
+ ? this.kernel.path("bin/npm/node_modules")
29
+ : this.kernel.path("bin/npm/lib/node_modules")
30
+ }
31
+
32
+ packageJsonPath() {
33
+ return path.resolve(this.moduleRoot(), this.packageName(), "package.json")
34
+ }
35
+
24
36
  installedArtifacts() {
25
37
  const binDir = this.npmBinDir()
26
38
  if (this.kernel.platform === "win32") {
@@ -38,7 +50,16 @@ class Bluefairy {
38
50
  }
39
51
 
40
52
  isInstalledSync() {
41
- return this.installedArtifacts().every((artifact) => fs.existsSync(artifact))
53
+ if (!this.installedArtifacts().every((artifact) => fs.existsSync(artifact))) {
54
+ return false
55
+ }
56
+ try {
57
+ const pkg = JSON.parse(fs.readFileSync(this.packageJsonPath(), "utf8"))
58
+ const coerced = semver.coerce(pkg && pkg.version)
59
+ return !!(coerced && semver.satisfies(coerced, this.version))
60
+ } catch (e) {
61
+ return false
62
+ }
42
63
  }
43
64
 
44
65
  async install(req, ondata) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "7.1.21",
3
+ "version": "7.1.22",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {