-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·45 lines (38 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
'use strict';
const colors = require('colors');
const async = require('asyncawait/async');
const await = require('asyncawait/await');
const init = require('./tasks/init');
const serve = require('./tasks/serve');
const timed = require('./tasks/timed');
const logger = require('./logger');
var args = process.argv.slice(2);
if (argIs(args[0], ['h', 'help'])) {
logger.empty();
logger.helpEntry('Usage:', 'html-lambda <command>');
logger.empty();
logger.helpEntry('Available Commands:', '');
logger.empty();
logger.helpEntry('init [i]:', 'Create a new project in the current directory.');
logger.helpEntry('serve [s]:', 'Run a local development server.');
logger.helpEntry('build [b]:', 'Build the lambda into a zip file, but don\'t deploy.');
logger.helpEntry('deploy [d]:', 'Build and deploy the lambda to the function specified in aws-config.json.');
} else if (argIs(args[0], ['i', 'init'])) {
init();
} else if (argIs(args[0], ['s', 'serve'])) {
serve();
} else if (argIs(args[0], ['b', 'build'])) {
timed.build();
} else if (argIs(args[0], ['d', 'deploy'])) {
timed.deploy();
} else {
if (!args[0]) {
logger.info('html-lambda', 'needs at least one argument. Run "html-lambda help" for help.');
} else {
logger.info('Unrecognized argument:', args[0]);
}
}
function argIs(arg, aliases) {
return aliases.indexOf(arg) > -1;
}