76 lines
1.6 KiB
JavaScript
Executable File
76 lines
1.6 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var path = require('path');
|
|
|
|
var cli = require('yargs').
|
|
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').substr(-47) // cleaner for long directories
|
|
}).
|
|
options('r', {
|
|
alias: 'runtime',
|
|
default: 'latest',
|
|
description: 'The node.js runtime to use'
|
|
}).
|
|
options('t', {
|
|
alias: 'temp',
|
|
default: '/tmp/nexe',
|
|
description: 'The path to store node.js sources'
|
|
}).
|
|
options('f', {
|
|
alias: 'flags',
|
|
description: 'Don\'t parse node and v8 flags, pass through app flags',
|
|
default: false
|
|
}).
|
|
options('v', {
|
|
alias: 'version',
|
|
description: 'Display version number'
|
|
}).
|
|
options('p', {
|
|
alias: 'python',
|
|
description: 'Set path of python to use.',
|
|
default: 'python'
|
|
}).
|
|
options('F', {
|
|
alias: 'framework',
|
|
description: 'Set the framework to use',
|
|
default: 'nodejs'
|
|
});
|
|
|
|
var argv = cli.argv;
|
|
|
|
if(argv.h || argv.help) {
|
|
cli.showHelp();
|
|
process.exit();
|
|
} else if (argv.v || argv.version) {
|
|
var pkginfo = require('../package.json');
|
|
console.log(pkginfo.version);
|
|
process.exit();
|
|
}
|
|
|
|
|
|
function toAbsolute(pt) {
|
|
if(pt.substr(0, 1) == "/") return pt;
|
|
return path.join(process.cwd(), pt);
|
|
}
|
|
|
|
require('../lib').compile({
|
|
input : require.resolve(toAbsolute(argv.i)),
|
|
output : toAbsolute(argv.o),
|
|
flags : argv.f,
|
|
nodeVersion : argv.r,
|
|
python : argv.python,
|
|
nodeTempDir : toAbsolute(argv.t),
|
|
framework : argv.F }, function(error) {
|
|
if(error) console.log(error.message);
|
|
});
|