2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 15:51:06 +00:00

Reformattted code with tabs and colons

This commit is contained in:
Jia Hao 2015-07-05 14:17:40 +08:00
parent 8ddeac3443
commit d40e605e98

40
cli.js
View File

@ -1,32 +1,32 @@
#!/usr/bin/env node #!/usr/bin/env node
var fs = require('fs') var fs = require('fs');
var args = require('minimist')(process.argv.slice(2), {boolean: ['prune', 'asar', 'all', 'overwrite']}) var args = require('minimist')(process.argv.slice(2), {boolean: ['prune', 'asar', 'all', 'overwrite']});
var packager = require('./') var packager = require('./');
var usage = fs.readFileSync(__dirname + '/usage.txt').toString() var usage = fs.readFileSync(__dirname + '/usage.txt').toString();
var validator = require('validator'); var validator = require('validator');
args.dir = './app'; args.dir = './app';
args.name = args._[0]; args.name = args._[0];
var protocolSchemes = [].concat(args.protocol || []) var protocolSchemes = [].concat(args.protocol || []);
var protocolNames = [].concat(args['protocol-name'] || []) var protocolNames = [].concat(args['protocol-name'] || []);
if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes.length) { if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes.length) {
args.protocols = protocolSchemes.map(function (scheme, i) { args.protocols = protocolSchemes.map(function (scheme, i) {
return {schemes: [scheme], name: protocolNames[i]} return {schemes: [scheme], name: protocolNames[i]};
}) })
} }
if (!validator.isURL(args.target)) { if (!validator.isURL(args.target)) {
console.error('Enter a valid target url'); console.error('Enter a valid target url');
process.exit(1) process.exit(1);
} }
if (!args.dir || !args.name || !args.version || !args.target || (!args.all && (!args.platform || !args.arch))) { if (!args.dir || !args.name || !args.version || !args.target || (!args.all && (!args.platform || !args.arch))) {
console.error(usage); console.error(usage);
process.exit(1) process.exit(1);
} }
var appArgs = { var appArgs = {
@ -37,13 +37,13 @@ var appArgs = {
fs.writeFileSync('./app/targetUrl.txt', JSON.stringify(appArgs)); fs.writeFileSync('./app/targetUrl.txt', JSON.stringify(appArgs));
packager(args, function done (err, appPaths) { packager(args, function done(err, appPaths) {
if (err) { if (err) {
if (err.message) console.error(err.message) if (err.message) console.error(err.message);
else console.error(err, err.stack) else console.error(err, err.stack);
process.exit(1) process.exit(1);
} }
if (appPaths.length > 1) console.error('Wrote new apps to:\n' + appPaths.join('\n')) if (appPaths.length > 1) console.error('Wrote new apps to:\n' + appPaths.join('\n'));
else if (appPaths.length === 1) console.error('Wrote new app to', appPaths[0]) else if (appPaths.length === 1) console.error('Wrote new app to', appPaths[0]);
}) });