Skip to content
Open
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
77 changes: 77 additions & 0 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ ModuleSmith.prototype.build = function build(description, callback) {
builder.stdout.pipe(process.stdout);
builder.stderr.pipe(process.stderr);
builder.on('exit', function (code) {
<<<<<<< HEAD
return code !== 0
? next(new Error('npm exited with code ' + code))
: next(null, description);
Expand Down Expand Up @@ -175,6 +176,15 @@ ModuleSmith.prototype.build = function build(description, callback) {
error.log = text;
error.code = 400;
return next(error);
=======
if (code !== 0) {
var err = new Error(description.execPath + ' exited with code ' + code);
err.stream = (fs.createReadStream(path.join(description.directories.rootdir, 'stdio.log'))).pipe(new BufferedStream());
next(err);
}
else {
next(null, description, builder);
>>>>>>> 480c61e... [dist] 0.1.3
}

next(null, buildDescription);
Expand Down Expand Up @@ -219,13 +229,22 @@ ModuleSmith.prototype.build = function build(description, callback) {
}
}),
function (mappings, next) {
<<<<<<< HEAD
var pkg = JSON.parse(mappings.package);
pkg.os = buildDescription.os;
if (buildDescription.command === 'install') {
pkg.bundledDependencies = mappings.installedDependencies;
}

next(null, buildDescription, pkg);
=======
var pkgJSON = JSON.parse(mappings.packageJSON);
if (!buildDescription.dontBundle) {
pkgJSON.os = buildDescription.os;
pkgJSON.bundledDependencies = mappings.installedDependencies;
}
next(null, buildDescription, pkgJSON);
>>>>>>> 480c61e... [dist] 0.1.3
}
], next);
},
Expand All @@ -241,6 +260,7 @@ ModuleSmith.prototype.build = function build(description, callback) {
return done(err);
}

<<<<<<< HEAD
var stream = fstream.Reader({
path: buildDescription.directories.module,
isDirectory: true,
Expand All @@ -259,6 +279,13 @@ ModuleSmith.prototype.build = function build(description, callback) {
//
buildDomain.removeListener('error', done);
self.perform('build.output', buildDescription, stream, done);
=======
var stream = fstream.Reader({ path: buildDescription.directories.moduledir, type: "Directory", isDirectory: true })
.pipe(tar.Pack({ noProprietary: true }))
.pipe(zlib.Gzip())
.pipe(new BufferedStream());
return self.perform('build.output', buildDescription, stream, done);
>>>>>>> 480c61e... [dist] 0.1.3
});
});
};
Expand All @@ -281,13 +308,24 @@ ModuleSmith.prototype.getPackageNodeVersion = function (description) {
// Extends the build `description` with defaults.
//
ModuleSmith.prototype.getBuildDescription = function (description) {
<<<<<<< HEAD
var rootdir = description.directories.root,
builddir = path.join(rootdir, 'build'),
buildDescription;

buildDescription = merge.recursive({}, this.defaults, {
os: this.defaults.os,
cpu: this.defaults.cpu,
=======
var rootdir = description.directories.rootdir;
var builddir = rootdir + '/build';
var buildDescription = merge.recursive({}, this.defaults, {
execPath: description.execPath || this.defaults.execPath,
argv: description.argv || this.defaults.argv,
os: this.defaults.os,
cpu: this.defaults.cpu,
packageJSON: description.packageJSON,
>>>>>>> 480c61e... [dist] 0.1.3
filename: description.filename,
command: description.command || 'install',
directories: {
Expand Down Expand Up @@ -434,15 +472,36 @@ ModuleSmith.prototype.prepareRepository = function (buildDescription, callback)
}

async.waterfall([
<<<<<<< HEAD
fs.readFile.bind(fs, pkgFile),
updatePackage,
=======
fs.readFile.bind(fs, pkg),
function (contents, callback) {
var pkgJSON = JSON.parse(contents);
buildDescription.version = semver.valid(buildDescription.version) ? buildDescription.version : self.getPackageNodeVersion(pkgJSON);
buildDescription.env['npm_config_node-version'] = buildDescription.version;
if (!buildDescription.version ) {
callback(new Error('No matching versions found'));
return;
}
buildDescription.env.npm_config_nodedir = path.join(buildDescription.env.npm_config_nodedir, buildDescription.version);
if (typeof pkgJSON.env === 'object' && pkgJSON.env && !Array.isArray(pkgJSON.env)) {
merge.recursive(buildDescription, {
env: pkgJSON.env
});
}
callback(null);
},
>>>>>>> 480c61e... [dist] 0.1.3
chownr.bind(chownr, dir, uid, gid)
], function (err) {
callback(err, buildDescription);
});
});
};

<<<<<<< HEAD
//
// ### function spawnNpm (description, callback)
// #### @description {Object} Build description to spawn npm for.
Expand All @@ -457,10 +516,22 @@ ModuleSmith.prototype.spawnNpm = function spawnNpm(description, callback) {
prefix;

options = {
=======
ModuleSmith.prototype.spawnNPM = function spawnNPM(description, callback) {
if (!description.execPath) {
callback(new Error('executable not specified'));
return;
}
var argv = description.execPath.match(/\S+|'(\\[\s\S]|[^'])'|"(\\[\s\S]|[^"])"/g);
var execPath = argv.shift();
argv = argv.concat(description.argv || []);
var builder = suspawn(execPath, argv.concat(description.options), {
>>>>>>> 480c61e... [dist] 0.1.3
uid: description.uid,
gid: description.gid,
cwd: description.directories.module,
env: description.env
<<<<<<< HEAD
};

//
Expand Down Expand Up @@ -522,5 +593,11 @@ ModuleSmith.prototype.spawnNpm = function spawnNpm(description, callback) {
}

builder = suspawn('npm', args, options);
=======
});
var log = fs.createWriteStream(path.join(description.directories.rootdir, 'stdio.log'));
builder.stdout.pipe(log);
builder.stderr.pipe(log);
>>>>>>> 480c61e... [dist] 0.1.3
callback(null, description, builder);
};