50 lines
991 B
JavaScript
Executable File
50 lines
991 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var path = require('path');
|
|
|
|
var cli = require('optimist').
|
|
usage('Usage: $0 -i [sources] -o [binary]').
|
|
options('i', {
|
|
demand: true,
|
|
alias: 'input',
|
|
desc: 'The entry javascript files',
|
|
default: process.cwd()
|
|
}).
|
|
options('o', {
|
|
demand: true,
|
|
alias: 'output',
|
|
desc: 'The output binary',
|
|
default: process.cwd() + '/release/' + path.basename(process.cwd()) + '.nex'
|
|
}).
|
|
options('r', {
|
|
alias: 'runtime',
|
|
default: '0.8.21',
|
|
description: 'The node.js runtime to use'
|
|
}).
|
|
options('t', {
|
|
alias: 'temp',
|
|
default: '/tmp/nexe',
|
|
description: 'The path to store node.js sources'
|
|
});
|
|
|
|
var argv = cli.argv;
|
|
|
|
|
|
if(argv.h || argv.help) {
|
|
cli.showHelp();
|
|
process.exit();
|
|
}
|
|
|
|
|
|
function toRelative(pt) {
|
|
if(pt.substr(0, 1) == "/") return pt;
|
|
return path.join(process.cwd(), pt);
|
|
}
|
|
|
|
|
|
|
|
require('../lib').compile({ input: toRelative(argv.i), output: toRelative(argv.o), runtime: argv.r, temp: toRelative(argv.t) }, function(error) {
|
|
|
|
if(error) console.log(error.message);
|
|
});
|