var derivePkgCore = require('derive-pkg-core');
var rebasePaths = require('./rebase-paths');

module.exports = derivePkg;

function derivePkg(baseDir, opts, callback) {
  if (typeof baseDir === 'undefined') {
    baseDir = '.';
  } else if (typeof baseDir === 'object') {
    callback = opts;
    opts = baseDir;
    baseDir = '.';
  }
  if (!opts.outDir) {
    throw Error('Error: No output directory specified.');
  }

  var transformPkg = function(pkg) {
    delete pkg.devDependencies;
    delete pkg.scripts;
    // Derived packages are intended for publishing; we can safely strip
    // their "private" key
    delete pkg.private;
    if (pkg.main) {
      pkg.main = rebasePaths(pkg.main, opts.outDir);
    }
    if (pkg.bin) {
      pkg.bin = rebasePaths(pkg.bin, opts.outDir);
    }
    if (pkg.browser) {
      pkg.browser = rebasePaths(pkg.browser, opts.outDir);
    }
    return pkg;
  };

  derivePkgCore({
    srcDir: baseDir,
    destDir: opts.outDir,
    transformFn: transformPkg
  }, callback);
}

@@ -631,16 +631,135 @@
 rivate;%0A
+    if (opts.name) %7B%0A      pkg.name = opts.name;%0A    %7D%0A    if (opts.version) %7B%0A      pkg.version = opts.version;%0A    %7D%0A
     if (

Add back main/version option