|
| 1 | +diff --git a/lib/pack-directory.js b/lib/pack-directory.js |
| 2 | +index d46069c78..2ba6bfea1 100644 |
| 3 | +--- a/lib/pack-directory.js |
| 4 | ++++ b/lib/pack-directory.js |
| 5 | +@@ -2,13 +2,13 @@ |
| 6 | + |
| 7 | + const path = require("path"); |
| 8 | + const figgyPudding = require("figgy-pudding"); |
| 9 | +-const packlist = require("npm-packlist"); |
| 10 | + const log = require("npmlog"); |
| 11 | +-const tar = require("tar"); |
| 12 | + const tempWrite = require("temp-write"); |
| 13 | + const getPacked = require("@lerna/get-packed"); |
| 14 | + const Package = require("@lerna/package"); |
| 15 | + const runLifecycle = require("@lerna/run-lifecycle"); |
| 16 | ++const util = require("util"); |
| 17 | ++const exec = util.promisify(require('child_process').exec); |
| 18 | + |
| 19 | + module.exports = packDirectory; |
| 20 | + |
| 21 | +@@ -40,34 +40,23 @@ function packDirectory(_pkg, dir, _opts) { |
| 22 | + chain = chain.then(() => pkg.refresh()); |
| 23 | + } |
| 24 | + |
| 25 | +- chain = chain.then(() => runLifecycle(pkg, "prepack", opts)); |
| 26 | +- chain = chain.then(() => pkg.refresh()); |
| 27 | +- chain = chain.then(() => packlist({ path: pkg.contents })); |
| 28 | +- chain = chain.then(files => |
| 29 | +- tar.create( |
| 30 | +- { |
| 31 | +- cwd: pkg.contents, |
| 32 | +- prefix: "package/", |
| 33 | +- portable: true, |
| 34 | +- // Provide a specific date in the 1980s for the benefit of zip, |
| 35 | +- // which is confounded by files dated at the Unix epoch 0. |
| 36 | +- mtime: new Date("1985-10-26T08:15:00.000Z"), |
| 37 | +- gzip: true, |
| 38 | +- }, |
| 39 | +- // NOTE: node-tar does some Magic Stuff depending on prefixes for files |
| 40 | +- // specifically with @ signs, so we just neutralize that one |
| 41 | +- // and any such future "features" by prepending `./` |
| 42 | +- files.map(f => `./${f}`) |
| 43 | +- ) |
| 44 | ++ // We need to call "yarn pack" to remove the "workspace:" protocol from |
| 45 | ++ // package.json before publishing |
| 46 | ++ chain = chain.then(() => tempWrite("", getTarballName(pkg))); |
| 47 | ++ chain = chain.then(tarFilePath => |
| 48 | ++ exec("yarn pack --out " + tarFilePath, { cwd: pkg.location }) |
| 49 | ++ .then(({ stdout, stderr }) => { |
| 50 | ++ const err = stderr.toString(); |
| 51 | ++ if (err) console.log(err); |
| 52 | ++ }) |
| 53 | ++ .then(() => tarFilePath) |
| 54 | + ); |
| 55 | +- chain = chain.then(stream => tempWrite(stream, getTarballName(pkg))); |
| 56 | + chain = chain.then(tarFilePath => |
| 57 | +- getPacked(pkg, tarFilePath).then(packed => |
| 58 | +- Promise.resolve() |
| 59 | +- .then(() => runLifecycle(pkg, "postpack", opts)) |
| 60 | +- .then(() => packed) |
| 61 | +- ) |
| 62 | ++ Promise.resolve() |
| 63 | ++ .then(() => pkg.refresh()) |
| 64 | ++ .then(() => tarFilePath) |
| 65 | + ); |
| 66 | ++ chain = chain.then(tarFilePath => getPacked(pkg, tarFilePath)); |
| 67 | + |
| 68 | + return chain; |
| 69 | + } |
| 70 | +@@ -81,3 +70,7 @@ function getTarballName(pkg) { |
| 71 | + |
| 72 | + return `${name}-${pkg.version}.tgz`; |
| 73 | + } |
| 74 | ++ |
| 75 | ++function tap(fn) { |
| 76 | ++ return arg => Promise.resolve(fn(arg)).then(() => arg); |
| 77 | ++} |
| 78 | +\ No newline at end of file |
| 79 | +diff --git a/package.json b/package.json |
| 80 | +index e00ac73ff..953512b2c 100644 |
| 81 | +--- a/package.json |
| 82 | ++++ b/package.json |
| 83 | +@@ -31,9 +31,7 @@ |
| 84 | + "@lerna/package": "3.16.0", |
| 85 | + "@lerna/run-lifecycle": "3.16.2", |
| 86 | + "figgy-pudding": "^3.5.1", |
| 87 | +- "npm-packlist": "^1.4.4", |
| 88 | + "npmlog": "^4.1.2", |
| 89 | +- "tar": "^4.4.10", |
| 90 | + "temp-write": "^3.4.0" |
| 91 | + }, |
| 92 | + "gitHead": "bb048cb306b5cfcb039aa98f667cf3751cf0ad20" |
0 commit comments