diff --git a/package.json b/package.json index 8d24e986..74deb72e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "debug": "^3.1.0" }, "devDependencies": { - "@oclif/errors": "^1.0.9", + "@oclif/errors": "^1.0.12", "@oclif/parser": "^3.3.3", "@oclif/tslint": "^1.1.1", "@types/chai": "^4.1.3", @@ -16,10 +16,10 @@ "@types/indent-string": "^3.0.0", "@types/lodash": "^4.14.108", "@types/mocha": "^5.2.0", - "@types/node": "^10.0.4", + "@types/node": "^10.0.8", "@types/wrap-ansi": "^3.0.0", "chai": "^4.1.2", - "fancy-test": "^1.0.6", + "fancy-test": "^1.0.8", "globby": "^8.0.1", "lodash": "^4.17.10", "mocha": "^5.1.1", diff --git a/src/config.ts b/src/config.ts index 8e5e4160..4202cc8d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -247,6 +247,7 @@ export class Config implements IConfig { if (this.options.userPlugins !== false) { try { const userPJSONPath = path.join(this.dataDir, 'package.json') + debug('reading user plugins pjson %s', userPJSONPath) const pjson = this.userPJSON = await loadJSON(userPJSONPath) if (!pjson.oclif) pjson.oclif = {schema: 1} await this.loadPlugins(userPJSONPath, 'user', pjson.oclif.plugins.filter((p: any) => p.type === 'user')) diff --git a/src/util.ts b/src/util.ts index 81e647ed..f1fa55df 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,6 +1,8 @@ // tslint:disable no-implicit-dependencies import * as fs from 'fs' +const debug = require('debug')('@oclif/config') + export function flatMap(arr: T[], fn: (i: T) => U[]): U[] { return arr.reduce((arr, i) => arr.concat(fn(i)), [] as U[]) } @@ -14,6 +16,7 @@ export function mapValues(obj: {[P in keyof T]: T[P]} } export function loadJSONSync(path: string): any { + debug('loadJSONSync %s', path) // let loadJSON // try { loadJSON = require('load-json-file') } catch {} // if (loadJSON) return loadJSON.sync(path) @@ -26,13 +29,18 @@ export function exists(path: string): Promise { } export function loadJSON(path: string): Promise { + debug('loadJSON %s', path) // let loadJSON // try { loadJSON = require('load-json-file') } catch {} // if (loadJSON) return loadJSON.sync(path) return new Promise((resolve, reject) => { fs.readFile(path, 'utf8', (err, d) => { - if (err) reject(err) - else resolve(JSON.parse(d)) + try { + if (err) reject(err) + else resolve(JSON.parse(d)) + } catch (err) { + reject(err) + } }) }) } diff --git a/yarn.lock b/yarn.lock index b2e986e4..4744d343 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,12 +2,12 @@ # yarn lockfile v1 -"@oclif/errors@^1.0.9": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@oclif/errors/-/errors-1.0.9.tgz#6fe3afd8e7683c436df63674550899adec10c81c" +"@oclif/errors@^1.0.12": + version "1.0.12" + resolved "https://registry.yarnpkg.com/@oclif/errors/-/errors-1.0.12.tgz#6c8ea932d3fcfc26f5b3bc77e45da8f33189f188" dependencies: clean-stack "^1.3.0" - fs-extra "^6.0.0" + fs-extra "^6.0.1" indent-string "^3.2.0" strip-ansi "^4.0.0" wrap-ansi "^3.0.1" @@ -71,9 +71,9 @@ version "9.4.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.5.tgz#d2a90c634208173d1b1a0a6ba9f1df3de62edcf5" -"@types/node@^10.0.4": - version "10.0.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.0.4.tgz#130598ee56e9a1210a53f557d64935571f05390d" +"@types/node@^10.0.8": + version "10.0.8" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.0.8.tgz#37b4d91d4e958e4c2ba0be2b86e7ed4ff19b0858" "@types/wrap-ansi@^3.0.0": version "3.0.0" @@ -425,9 +425,9 @@ extglob@^2.0.2: snapdragon "^0.8.1" to-regex "^3.0.1" -fancy-test@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/fancy-test/-/fancy-test-1.0.6.tgz#e0a061ecdcfb9d8fbea1f86375ed26e258ed7243" +fancy-test@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/fancy-test/-/fancy-test-1.0.8.tgz#d66a5ffab73a0792bf3c8404812c5a774f0e3180" dependencies: lodash "^4.17.10" stdout-stderr "^0.1.9" @@ -460,9 +460,9 @@ fragment-cache@^0.2.1: dependencies: map-cache "^0.2.2" -fs-extra@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.0.tgz#0f0afb290bb3deb87978da816fcd3c7797f3a817" +fs-extra@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b" dependencies: graceful-fs "^4.1.2" jsonfile "^4.0.0"