1
0
mirror of https://github.com/jiahaog/Nativefier synced 2024-07-01 08:20:50 +02:00
Nativefier/cli.js

33 lines
938 B
JavaScript
Raw Normal View History

2015-03-23 03:51:19 +01:00
#!/usr/bin/env node
var fs = require('fs')
var args = require('minimist')(process.argv.slice(2), {boolean: ['prune', 'asar']})
2015-03-23 03:51:19 +01:00
var packager = require('./')
var usage = fs.readFileSync(__dirname + '/usage.txt').toString()
2015-03-23 03:51:19 +01:00
args.dir = args._[0]
args.name = args._[1]
2015-04-05 06:28:06 +02:00
var protocolSchemes = [].concat(args.protocol || [])
var protocolNames = [].concat(args['protocol-name'] || [])
2015-04-05 06:13:27 +02:00
if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes.length) {
2015-04-05 06:28:06 +02:00
args.protocols = protocolSchemes.map(function (scheme, i) {
2015-04-05 06:13:27 +02:00
return {schemes: [scheme], name: protocolNames[i]}
})
}
if (!args.dir || !args.name || !args.platform || !args.arch || !args.version) {
console.error(usage)
2015-03-23 03:51:19 +01:00
process.exit(1)
}
2015-03-23 03:51:19 +01:00
packager(args, function done (err, appPath) {
if (err) {
2015-05-11 21:11:40 +02:00
if (err.message) console.error(err.message)
else console.error(err, err.stack)
process.exit(1)
2015-03-23 03:51:19 +01:00
}
2015-03-23 03:51:19 +01:00
console.error('Wrote new app to', appPath)
})