Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7a187bcfa0
Fetching contributors…

Cannot retrieve contributors at this time

executable file 125 lines (98 sloc) 1.883 kb
#!/usr/bin/env node
var slugr = require('../lib'),
fs = require('fs');
var args = process.argv.concat(),
ops = {},
slugFile;
//first two are crap
args.shift();
args.shift();
function loadConfig(path, cwd)
{
var cfg = fs.readFileSync(path, 'utf8');
cfg = cfg.replace(/\.\//g,cwd || process.cwd());
var cfg = JSON.parse(cfg);
//the config *may* have been loaded after other stuff, so copy it over instead overwriting it
for(var property in cfg)
{
ops[property] = cfg[property];
}
return ops;
}
while(args.length)
{
var arg = args.shift();
switch(arg)
{
//where the slug is being saved to
case '-o':
case '-output':
ops.output = args.shift();
break;
//input file for the slug
case '-i':
case '-input':
ops.input = args.shift();
break;
//if provided, NPM bundles all dependencies into one
case '-b':
case '-bundle':
ops.bundle = true;
break;
//version of the slug being generated
case '-v':
case '-version':
ops.version = args.shift();
break
//the name of the slug
case '-n':
case '-name':
ops.main = args.shift();
break;
//loads a config up
case '-c':
case '-config':
loadConfig(args.shift())
break;
//the arguments for the slug file
case '-a':
case '-args':
ops.args = [];
while(args.length)
{
ops.args.push(args.shift())
}
break;
//default = run this slug
default:
slugFile = arg;
break;
}
}
if(ops.input)
{
slugr.write(ops, function()
{
});
}
else
if(slugFile)
{
slugr.run(slugFile);
}
//build from config
else
{
//var cwd = '/Users/craigcondon/Dropbox/work/Spice2/spice.io/servers/spiceio/';//process.cwd();
var cwd = process.cwd() + '/';
try
{
slugr.write(loadConfig(cwd + '/package.json', cwd), function()
{
})
}
catch(e)
{
console.error('Could not locate package.json in %s', cwd);
}
}
Jump to Line
Something went wrong with that request. Please try again.