Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fstream-npm #234

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 15 additions & 32 deletions lib/jitsu/package.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,37 +8,18 @@
var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
util = require('util'), util = require('util'),
zlib = require('zlib'),
async = require('flatiron').common.async, async = require('flatiron').common.async,
analyzer = require('require-analyzer'), analyzer = require('require-analyzer'),
npm = require('npm'), npm = require('npm'),
npmout = require('npm/lib/utils/output'),
semver = require('semver'), semver = require('semver'),
jitsu = require('../jitsu'); jitsu = require('../jitsu'),
fstream = require('fstream'),
fstreamNpm = require('fstream-npm'),
tar = require('tar');


var package = exports; 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) // ### function get (dir, callback)
// #### @dir {string} Directory to get the package.json from // #### @dir {string} Directory to get the package.json from
Expand Down Expand Up @@ -375,14 +356,16 @@ package.createTarball = function (dir, version, callback) {
tarball = path.join(jitsu.config.get('tmproot'), name); tarball = path.join(jitsu.config.get('tmproot'), name);


npm.load({ exit: false }, function () { npm.load({ exit: false }, function () {
// fstreamNpm({ path: dir })
// Lazy load `npmtar`, then use it to package .on('error', callback)
// the specified tarball. .pipe(tar.Pack())
// .on('error', callback)
npmtar = npmtar || require('npm/lib/utils/tar'); .pipe(zlib.Gzip())
npmtar.pack(tarball, dir, pkg, true, function (err) { .on('error', callback)
return err ? callback(err) : callback(null, pkg, tarball); .pipe(fstream.Writer({ type: "File", path: tarball }))
}); .on('close', function () {
callback(null, pkg, tarball);
});
}); });
}); });
}; };
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"request": "2.9.100", "request": "2.9.100",
"require-analyzer": "0.4.0-3", "require-analyzer": "0.4.0-3",
"semver": "1.0.13", "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": { "devDependencies": {
"nock": "0.8.x", "nock": "0.8.x",
Expand Down