Skip to content

Commit

Permalink
feat(run-lifecycle): Resolve target package to aid chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Aug 27, 2018
1 parent 928a707 commit 8e0aa96
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions commands/__mocks__/@lerna/run-lifecycle.js
@@ -1,12 +1,12 @@
"use strict";

const mockRunLifecycle = jest.fn(() => Promise.resolve());
const mockRunLifecycle = jest.fn(pkg => Promise.resolve(pkg));
const mockCreateRunner = jest.fn(() => (pkg, stage) => {
if (pkg.scripts[stage]) {
return mockRunLifecycle(pkg, stage);
}

return Promise.resolve();
return Promise.resolve(pkg);
});

function getOrderedCalls() {
Expand Down
6 changes: 4 additions & 2 deletions utils/run-lifecycle/__tests__/run-lifecycle.test.js
Expand Up @@ -17,8 +17,9 @@ describe("default export", () => {
const stage = "preversion";
const config = npmConf({ "custom-cli-flag": true });

await runLifecycle(pkg, stage, config);
const result = await runLifecycle(pkg, stage, config);

expect(result).toBe(pkg);
expect(npmLifecycle).lastCalledWith(
expect.objectContaining({
name: pkg.name,
Expand Down Expand Up @@ -54,8 +55,9 @@ describe("createRunner", () => {
};
const stage = "version";

await runPackageLifecycle(pkg, stage);
const result = await runPackageLifecycle(pkg, stage);

expect(result).toBe(pkg);
expect(npmLifecycle).lastCalledWith(
expect.any(Object),
stage,
Expand Down
4 changes: 2 additions & 2 deletions utils/run-lifecycle/run-lifecycle.js
Expand Up @@ -34,7 +34,7 @@ function runLifecycle(pkg, stage, opts) {
failOk: false,
log,
unsafePerm: true,
});
}).then(() => pkg);
}

function createRunner(commandOptions) {
Expand All @@ -47,6 +47,6 @@ function createRunner(commandOptions) {
});
}

return Promise.resolve();
return Promise.resolve(pkg);
};
}

0 comments on commit 8e0aa96

Please sign in to comment.