Repository: prettier/prettier-atom (js)

Issue:
Debug command returns undefined for package versions
Seen on recent issues.

Example:


<details>

```
Atom version: 1.18.0
prettier-atom version: undefined
prettier version: undefined
prettier-eslint version: undefined
prettier-atom configuration: {
  "formatOnSaveOptions": {
    "enabled": true,
    "respectEslintignore": true,
    "showInStatusBar": false,
    "javascriptScopes": [
      "source.js",
      "source.jsx",
      "source.js.jsx",
      "source.babel",
      "source.js-semantic",
      "text.html.basic",
      "text.html.vue"
    ],
    "typescriptScopes": [
      "source.ts",
      "source.tsx",
      "source.ts.tsx"
    ],
    "cssScopes": [
      "source.css",
      "source.less",
      "source.css.less",
      "source.scss",
      "source.css.scss"
    ],
    "excludedGlobs": [],
    "whitelistedGlobs": [],
    "isDisabledIfNotInPackageJson": false
  },
  "prettierEslintOptions": {
    "prettierLast": false
  },
  "prettierOptions": {
    "semi": false,
    "singleQuote": true,
    "bracketSpacing": true,
    "useTabs": false,
    "jsxBracketSameLine": false,
    "printWidth": 80,
    "tabWidth": "auto",
    "trailingComma": "none",
    "parser": "babylon"
  },
  "useEslint": true,
  "silenceErrors": false,
  "useEditorConfig": true
}
```
</details>

Pull request description:
fix(debug): Fix usage of readPkgUp to fetch package info
read-pkg and read-pkg-up do not have the same API.

Fixes #217

Patch:
diff --git a/dist/displayDebugInfo/index.js b/dist/displayDebugInfo/index.js
index 8061dc2..fe6e424 100644
--- a/dist/displayDebugInfo/index.js
+++ b/dist/displayDebugInfo/index.js
@@ -12,8 +12,12 @@ var getDepPath = function getDepPath(dep) {
   return path.join(__dirname, '..', '..', 'node_modules', dep);
 };
 
+var getPackageInfo = function getPackageInfo(dir) {
+  return readPkgUp.sync({ cwd: dir }).pkg;
+};
+
 var getDebugInfo = function getDebugInfo() {
-  return ('\nAtom version: ' + getAtomVersion() + '\nprettier-atom version: ' + readPkgUp.sync(__dirname).version + '\nprettier version: ' + readPkgUp.sync(getDepPath('prettier')).version + '\nprettier-eslint version: ' + readPkgUp.sync(getDepPath('prettier-eslint')).version + '\nprettier-atom configuration: ' + JSON.stringify(getPrettierAtomConfig(), null, 2) + '\n').trim();
+  return ('\nAtom version: ' + getAtomVersion() + '\nprettier-atom version: ' + getPackageInfo(__dirname).version + '\nprettier version: ' + getPackageInfo(getDepPath('prettier')).version + '\nprettier-eslint version: ' + getPackageInfo(getDepPath('prettier-eslint')).version + '\nprettier-atom configuration: ' + JSON.stringify(getPrettierAtomConfig(), null, 2) + '\n').trim();
 };
 
 var displayDebugInfo = function displayDebugInfo() {
diff --git a/src/displayDebugInfo/index.js b/src/displayDebugInfo/index.js
index 47a9360..191ed97 100644
--- a/src/displayDebugInfo/index.js
+++ b/src/displayDebugInfo/index.js
@@ -5,12 +5,14 @@ const { getAtomVersion, getPrettierAtomConfig, addInfoNotification } = require('
 
 const getDepPath = (dep: string) => path.join(__dirname, '..', '..', 'node_modules', dep);
 
+const getPackageInfo = (dir: string) => readPkgUp.sync({ cwd: dir }).pkg;
+
 const getDebugInfo = () =>
   `
 Atom version: ${getAtomVersion()}
-prettier-atom version: ${readPkgUp.sync(__dirname).version}
-prettier version: ${readPkgUp.sync(getDepPath('prettier')).version}
-prettier-eslint version: ${readPkgUp.sync(getDepPath('prettier-eslint')).version}
+prettier-atom version: ${getPackageInfo(__dirname).version}
+prettier version: ${getPackageInfo(getDepPath('prettier')).version}
+prettier-eslint version: ${getPackageInfo(getDepPath('prettier-eslint')).version}
 prettier-atom configuration: ${JSON.stringify(getPrettierAtomConfig(), null, 2)}
 `.trim();
 


Test patch:
diff --git a/src/displayDebugInfo/index.test.js b/src/displayDebugInfo/index.test.js
index b750018..44cdc5e 100644
--- a/src/displayDebugInfo/index.test.js
+++ b/src/displayDebugInfo/index.test.js
@@ -12,7 +12,11 @@ test('it displays a notification on Atom with package information', () => {
     title = _title;
     options = _options;
   });
-  readPkgUp.sync.mockImplementation(() => ({ version: 'FAKE_PACKAGE_VERSION' }));
+  readPkgUp.sync.mockImplementation(() => ({
+    pkg: {
+      version: 'FAKE_PACKAGE_VERSION',
+    },
+  }));
   getAtomVersion.mockImplementation(() => 'FAKE_ATOM_VERSION');
   getPrettierAtomConfig.mockImplementation(() => 'FAKE_PRETTIER_ATOM_CONFIG');