Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use `fstream-npm` #234

Closed
wants to merge 2 commits into from

2 participants

@mmalecki

This basically reproduces the logic in npm/lib/utils/tar module
without the need to monkey punch npm/lib/utils/output.

Please give it a fair amount of testing before merging (it works for me).

mmalecki added some commits
@mmalecki mmalecki [refactor] Use `fstream-npm` for packaging tarballs
This basically reproduces the logic in `npm/lib/utils/tar` module
without the need to monkey punch `npm/lib/utils/output`.
a51b55f
@mmalecki mmalecki [dist] Add `fstream`, `fstream-npm` and `tar` dependencies 70717e6
@indexzero
Owner

Cherry-picked.

@indexzero indexzero closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 2, 2012
  1. @mmalecki

    [refactor] Use `fstream-npm` for packaging tarballs

    mmalecki authored
    This basically reproduces the logic in `npm/lib/utils/tar` module
    without the need to monkey punch `npm/lib/utils/output`.
  2. @mmalecki
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 33 deletions.
  1. +15 −32 lib/jitsu/package.js
  2. +4 −1 package.json
View
47 lib/jitsu/package.js
@@ -8,38 +8,19 @@
var fs = require('fs'),
path = require('path'),
util = require('util'),
+ zlib = require('zlib'),
async = require('flatiron').common.async,
analyzer = require('require-analyzer'),
npm = require('npm'),
- npmout = require('npm/lib/utils/output'),
semver = require('semver'),
- jitsu = require('../jitsu');
+ jitsu = require('../jitsu'),
+ fstream = require('fstream'),
+ fstreamNpm = require('fstream-npm'),
+ tar = require('tar');
var package = exports;
//
-// Monkey patch `npmout.write()` so that we don't need log or out files
-//
-npmout.write = function () {
- var args = Array.prototype.slice.call(arguments),
- callback;
-
- args.forEach(function (arg) {
- if (typeof arg === 'function') {
- callback = arg;
- }
- });
-
- callback();
-};
-
-//
-// Setup `npmtar` to be a lazy loaded variable that
-// isn't setup until `npm.load` is invoked.
-//
-var npmtar;
-
-//
// ### function get (dir, callback)
// #### @dir {string} Directory to get the package.json from
// #### @options {object} Ignored
@@ -375,14 +356,16 @@ package.createTarball = function (dir, version, callback) {
tarball = path.join(jitsu.config.get('tmproot'), name);
npm.load({ exit: false }, function () {
- //
- // Lazy load `npmtar`, then use it to package
- // the specified tarball.
- //
- npmtar = npmtar || require('npm/lib/utils/tar');
- npmtar.pack(tarball, dir, pkg, true, function (err) {
- return err ? callback(err) : callback(null, pkg, tarball);
- });
+ fstreamNpm({ path: dir })
+ .on('error', callback)
+ .pipe(tar.Pack())
+ .on('error', callback)
+ .pipe(zlib.Gzip())
+ .on('error', callback)
+ .pipe(fstream.Writer({ type: "File", path: tarball }))
+ .on('close', function () {
+ callback(null, pkg, tarball);
+ });
});
});
};
View
5 package.json
@@ -27,7 +27,10 @@
"request": "2.9.100",
"require-analyzer": "0.4.0-3",
"semver": "1.0.13",
- "complete": "0.3.x"
+ "complete": "0.3.x",
+ "tar": "0.1.x",
+ "fstream": "0.1.x",
+ "fstream-npm": "0.0.x"
},
"devDependencies": {
"nock": "0.8.x",
Something went wrong with that request. Please try again.