diff --git a/lib/builder.js b/lib/builder.js index 247308a..c0a67e0 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -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); @@ -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); @@ -219,6 +229,7 @@ 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') { @@ -226,6 +237,14 @@ ModuleSmith.prototype.build = function build(description, callback) { } 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); }, @@ -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, @@ -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 }); }); }; @@ -281,6 +308,7 @@ 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; @@ -288,6 +316,16 @@ ModuleSmith.prototype.getBuildDescription = function (description) { 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: { @@ -434,8 +472,28 @@ 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); @@ -443,6 +501,7 @@ ModuleSmith.prototype.prepareRepository = function (buildDescription, callback) }); }; +<<<<<<< HEAD // // ### function spawnNpm (description, callback) // #### @description {Object} Build description to spawn npm for. @@ -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 }; // @@ -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); };