Repository: prettier/prettier-atom
Pull request #803 (2020-06-20 03:12:30)

fix(debug): fix error with debug due to change in readPgkUp API
re #734 re #739


Patch:
diff --git a/dist/displayDebugInfo/index.js b/dist/displayDebugInfo/index.js
index 6d4987d..3aed2fd 100644
--- a/dist/displayDebugInfo/index.js
+++ b/dist/displayDebugInfo/index.js
@@ -18,7 +18,7 @@ const getDepPath = dep => path.join(__dirname, '..', '..', 'node_modules', dep);
 
 const getPackageInfo = dir => readPkgUp.sync({
   cwd: dir
-})["package"];
+}).packageJson;
 
 const getDebugInfo = () => {
   const globalPrettierPath = getGlobalPrettierPath();
diff --git a/src/displayDebugInfo/index.js b/src/displayDebugInfo/index.js
index 53e61ef..66ee826 100644
--- a/src/displayDebugInfo/index.js
+++ b/src/displayDebugInfo/index.js
@@ -6,7 +6,7 @@ const { getGlobalPrettierPath } = require('../helpers/getPrettierPath');
 
 const getDepPath = (dep: string) => path.join(__dirname, '..', '..', 'node_modules', dep);
 
-const getPackageInfo = (dir: string) => readPkgUp.sync({ cwd: dir }).package;
+const getPackageInfo = (dir: string) => readPkgUp.sync({ cwd: dir }).packageJson;
 
 const getDebugInfo = () => {
   const globalPrettierPath = getGlobalPrettierPath();


Test patch:
diff --git a/dist/displayDebugInfo/index.test.js b/dist/displayDebugInfo/index.test.js
index b819ece..0f6a4f3 100644
--- a/dist/displayDebugInfo/index.test.js
+++ b/dist/displayDebugInfo/index.test.js
@@ -26,7 +26,7 @@ test('it displays a notification on Atom with package information', () => {
     options = _options;
   });
   readPkgUp.sync.mockImplementation(() => ({
-    "package": {
+    packageJson: {
       version: 'FAKE_PACKAGE_VERSION'
     }
   }));
diff --git a/dist/formatOnSave/isPrettierInPackageJson.test.js b/dist/formatOnSave/isPrettierInPackageJson.test.js
index 2596b0e..714a3f8 100644
--- a/dist/formatOnSave/isPrettierInPackageJson.test.js
+++ b/dist/formatOnSave/isPrettierInPackageJson.test.js
@@ -29,7 +29,7 @@ describe('when shouldUseEslint is false', () => {
   });
   it('is true if prettier is a dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         dependencies: {
           prettier: '^0.0.1'
         }
@@ -40,7 +40,7 @@ describe('when shouldUseEslint is false', () => {
   });
   it('is true if prettier is a dev dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         devDependencies: {
           prettier: '^0.0.1'
         }
@@ -67,7 +67,7 @@ describe('when shouldUseEslint is true', () => {
   });
   it('is true if prettier-eslint is a dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         dependencies: {
           'prettier-eslint': '^0.0.1'
         }
@@ -78,7 +78,7 @@ describe('when shouldUseEslint is true', () => {
   });
   it('is true if prettier-eslint is a dev dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         devDependencies: {
           'prettier-eslint': '^0.0.1'
         }
@@ -89,7 +89,7 @@ describe('when shouldUseEslint is true', () => {
   });
   it('is true if prettier-eslint-cli is a dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         dependencies: {
           'prettier-eslint-cli': '^0.0.1'
         }
@@ -100,7 +100,7 @@ describe('when shouldUseEslint is true', () => {
   });
   it('is true if prettier-eslint-cli is a dev dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         devDependencies: {
           'prettier-eslint-cli': '^0.0.1'
         }
@@ -111,7 +111,7 @@ describe('when shouldUseEslint is true', () => {
   });
   it('is true if eslint-plugin-prettier is a dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         dependencies: {
           'eslint-plugin-prettier': '^0.0.1'
         }
@@ -122,7 +122,7 @@ describe('when shouldUseEslint is true', () => {
   });
   it('is true if eslint-plugin-prettier is a dev dependency', () => {
     readPkgUp.sync.mockImplementation(() => ({
-      "packageJson": {
+      packageJson: {
         devDependencies: {
           'eslint-plugin-prettier': '^0.0.1'
         }
@@ -135,4 +135,4 @@ describe('when shouldUseEslint is true', () => {
     const actual = isPrettierInPackageJson();
     expect(actual).toBe(false);
   });
-});
+});
\ No newline at end of file
diff --git a/src/displayDebugInfo/index.test.js b/src/displayDebugInfo/index.test.js
index d3f2c1f..c3acad3 100644
--- a/src/displayDebugInfo/index.test.js
+++ b/src/displayDebugInfo/index.test.js
@@ -15,7 +15,7 @@ test('it displays a notification on Atom with package information', () => {
     options = _options;
   });
   readPkgUp.sync.mockImplementation(() => ({
-    package: {
+    packageJson: {
       version: 'FAKE_PACKAGE_VERSION',
     },
   }));