#!/usr/bin/env node
var program = require('commander'),
    globalify = require('./globalify'),
    packageJson = require('./package.json'),
    fs = require('fs');

program
    .version(packageJson.version)
    .usage('<module> [options]')
    .arguments('<module>')
    .option('-o, --out <outputFileName>', 'the output path')
    .option('-g, --globalVariable [globalVariable]', 'the name of the global variable to expose')
    .parse(process.argv);

if (program.args.length !== 1) {
    program.help()
}

var moduleNameAndVersion = program.args[0].split('@'),
    moduleName = moduleNameAndVersion[0],
    version = moduleNameAndVersion[1] || 'x.x.x';

var outStream = fs.createWriteStream(program.out || moduleName + '.js');

globalify({
        module: moduleName,
        version: version,
        globalVariable: program.globalVariable,
        installDirectory: packageJson.installDirectory
    },
    function(error){
        if(error){
            console.log(error);
        }
    }
).pipe(outStream);

@@ -498,16 +498,17 @@
 m.help()
+;
 %0A%7D%0A%0Avar 
@@ -513,30 +513,24 @@
 r module
-NameAndVersion
+Argument
  = progr
@@ -539,16 +539,161 @@
 .args%5B0%5D
+;%0A%0Avar moduleNodes, moduleName, version;%0Aif (moduleArgument.indexOf('@') === 0) %7B%0A    // scoped package%0A    moduleNodes = moduleArgument.slice(1)
 .split('
@@ -695,17 +695,17 @@
 lit('@')
-,
+;
 %0A    mod
@@ -713,24 +713,30 @@
 leName =
+ '@' +
  moduleN
 ameAndVe
@@ -731,60 +731,128 @@
 uleN
-ameAndVersion%5B0%5D,%0A    version = moduleNameAndVersion
+odes%5B0%5D;%0A%7D%0Aelse %7B%0A    moduleNodes = moduleArgument.split('@');%0A    moduleName = moduleNodes%5B0%5D;%0A%7D%0A%0Aversion = moduleNodes
 %5B1%5D 
@@ -926,16 +926,34 @@
 duleName
+.replace('/', '-')
  + '.js'

Add support for scoped package