From 7c1405e24a493c937c1c9492972bd38ea9684567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Ulzurrun=20de=20Asanza=20i=20S=C3=A0ez?= Date: Thu, 12 Dec 2019 08:29:18 +0100 Subject: [PATCH] :bug: Fix `cwd` in `getPackagePublishedInfo` --- src/utils.ts | 2 +- test/utils.spec.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 05320b5..63a90cf 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -35,7 +35,7 @@ async function getPackagePublishedInfo (cwd: string): Promise { const pathToPackageJson = await module.exports.findPackageJsonFile(cwd) const packageName = await module.exports.getPackageName(cwd) - return module.exports.runShellScript(`yarn info '${packageName}' --json`, pathToPackageJson) + return module.exports.runShellScript(`yarn info '${packageName}' --json`, path.dirname(pathToPackageJson)) } async function findPackageJsonFile (cwd: string): Promise { diff --git a/test/utils.spec.ts b/test/utils.spec.ts index b185a96..4ec9658 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -62,13 +62,13 @@ describe('Utils', function () { describe('#getPackagePublishedInfo', function () { it('Should return run yarn info with proper package name', async function () { - sandbox.stub(utils, 'findPackageJsonFile').resolves('my path') + sandbox.stub(utils, 'findPackageJsonFile').resolves('my-path/package.json') sandbox.stub(utils, 'getPackageName').resolves('my name') sandbox.stub(utils, 'runShellScript').resolves('my response') await expect(utils.getPackagePublishedInfo('')).to.eventually.equal('my response') - expect(utils.runShellScript).to.have.been.calledOnceWithExactly('yarn info \'my name\' --json', 'my path') + expect(utils.runShellScript).to.have.been.calledOnceWithExactly('yarn info \'my name\' --json', 'my-path') }) })