@data-fair/lib-node 2.10.2 → 2.11.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/upgrade-scripts.js +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-node",
3
- "version": "2.10.2",
3
+ "version": "2.11.0",
4
4
  "description": "Small nodejs related utility functions for the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -25,9 +25,18 @@ export default async function (db, locks, basePath = './', isFresh) {
25
25
  }
26
26
  async function runScripts(db, basePath, isFresh) {
27
27
  const dir = path.resolve(basePath);
28
+ // in the case of workspaces the parent package.json is the right place to look for name and versions
29
+ const parentPjsonPath = path.join(dir, '../package.json');
28
30
  const pjsonPath = path.join(dir, 'package.json');
29
- debug('read service info from ' + pjsonPath);
30
- const pjson = JSON.parse(readFileSync(pjsonPath, 'utf8'));
31
+ let pjson;
32
+ try {
33
+ pjson = JSON.parse(readFileSync(parentPjsonPath, 'utf8'));
34
+ debug('read service info from ' + parentPjsonPath);
35
+ }
36
+ catch (err) {
37
+ pjson = JSON.parse(readFileSync(pjsonPath, 'utf8'));
38
+ debug('read service info from ' + pjsonPath);
39
+ }
31
40
  const scriptsRoot = path.join(dir, 'upgrade');
32
41
  debug(`service=${pjson.name} version=${pjson.version}`);
33
42
  const services = db.collection('services');