Skip to content

Commit

Permalink
refactor(pack-directory): Use figgy-pudding to wrap options, snapshot…
Browse files Browse the repository at this point in the history
… conf in test
  • Loading branch information
evocateur committed Dec 19, 2018
1 parent 24b0dc5 commit d0c677f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion commands/publish/index.js
Expand Up @@ -81,7 +81,7 @@ class PublishCommand extends Command {
this.logger.verbose("user-agent", userAgent);

this.conf = npmConf({
command: "publish",
lernaCommand: "publish",
log: this.logger,
npmSession,
npmVersion: userAgent,
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion utils/pack-directory/__tests__/pack-directory.test.js
Expand Up @@ -72,7 +72,7 @@ describe("pack-directory", () => {
jest.spyOn(fs, "move");

const cwd = await initFixture("lerna-bootstrap");
const conf = npmConf({ prefix: cwd });
const conf = npmConf({ prefix: cwd }).snapshot;
const pkgs = await getPackages(cwd);

// choose first and last package since the middle two are repetitive
Expand Down
15 changes: 12 additions & 3 deletions utils/pack-directory/lib/pack-directory.js
@@ -1,5 +1,6 @@
"use strict";

const figgyPudding = require("figgy-pudding");
const packlist = require("npm-packlist");
const tar = require("tar");
const tempWrite = require("temp-write");
Expand All @@ -8,7 +9,15 @@ const runLifecycle = require("@lerna/run-lifecycle");

module.exports = packDirectory;

function packDirectory(pkg, opts) {
const PackConfig = figgyPudding({
"lerna-command": { default: "pack" },
lernaCommand: "lerna-command",
"ignore-prepublish": {},
ignorePrepublish: "ignore-prepublish",
});

function packDirectory(pkg, _opts) {
const opts = PackConfig(_opts);
const dir = pkg.location;
const name =
pkg.name[0] === "@"
Expand All @@ -19,13 +28,13 @@ function packDirectory(pkg, opts) {

let chain = Promise.resolve();

if (opts.get("ignore-prepublish") !== false) {
if (opts.ignorePrepublish !== false) {
chain = chain.then(() => runLifecycle(pkg, "prepublish", opts));
}

chain = chain.then(() => runLifecycle(pkg, "prepare", opts));

if (opts.get("command") === "publish") {
if (opts.lernaCommand === "publish") {
chain = chain.then(() => pkg.refresh());
chain = chain.then(() => runLifecycle(pkg, "prepublishOnly", opts));
chain = chain.then(() => pkg.refresh());
Expand Down
1 change: 1 addition & 0 deletions utils/pack-directory/package.json
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"@lerna/get-packed": "file:../get-packed",
"@lerna/run-lifecycle": "file:../run-lifecycle",
"figgy-pudding": "^3.5.1",
"npm-packlist": "^1.1.12",
"tar": "^4.4.8",
"temp-write": "^3.4.0"
Expand Down

0 comments on commit d0c677f

Please sign in to comment.