diff --git a/CHANGELOG.md b/CHANGELOG.md index 5beb285..2701e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +#### 0.3.4 + + - Update dependencies + #### 0.3.3 - Add plugin stub to runtime (#73) @joepavitt diff --git a/index.js b/index.js index c9ac2e8..afd2180 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ 'use strict'; const path = require("path"); +const process = require("process") const sinon = require("sinon"); const should = require('should'); const fs = require('fs'); @@ -25,17 +26,35 @@ var bodyParser = require("body-parser"); const express = require("express"); const http = require('http'); const stoppable = require('stoppable'); -const readPkgUp = require('read-pkg-up'); const semver = require('semver'); const EventEmitter = require('events').EventEmitter; const PROXY_METHODS = ['log', 'status', 'warn', 'error', 'debug', 'trace', 'send']; + +// Find the nearest package.json +function findPackageJson(dir) { + dir = path.resolve(dir || process.cwd()) + const { root } = path.parse(dir) + if (dir === root) { + return null + } + const packagePath = path.join(dir, 'package.json') + if (fs.existsSync(packagePath)) { + return { + path: packagePath, + packageJson: JSON.parse(fs.readFileSync(packagePath, 'utf-8')) + } + } else { + return findPackageJson(path.resolve(path.join(dir, '..'))) + } +} + /** * Finds the NR runtime path by inspecting environment */ function findRuntimePath() { - const upPkg = readPkgUp.sync(); + const upPkg = findPackageJson() // case 1: we're in NR itself if (upPkg.packageJson.name === 'node-red') { if (checkSemver(upPkg.packageJson.version,"<0.20.0")) { diff --git a/package.json b/package.json index 2819d05..7ae5427 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ }, "dependencies": { "body-parser": "^1.20.2", - "express": "^4.18.2", - "read-pkg-up": "^7.0.1", + "express": "^4.19.2", "semver": "^7.5.4", "should": "^13.2.3", "should-sinon": "^0.0.6",