-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·55 lines (50 loc) · 1.51 KB
/
index.js
File metadata and controls
executable file
·55 lines (50 loc) · 1.51 KB
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
46
47
48
49
50
51
52
53
54
55
#! /usr/bin/env node
/**
*
* astro-cli - Entrypoint for Astro CLI commands
*
**/
'use strict';
var help = require('./src/messages/help');
var chokidar = require('chokidar')
, chalk = require('chalk')
, parseArgv = require('./src/parseArgv')
, aliases = require('./src/aliases')()
, processCommands = require('./src/processCommands')
, processCommandsInContainer = require('./src/processCommandsInContainer')
, processInstallCommands = require('./src/processInstallCommands')
, processAliasCommands = require('./src/processAliasCommands')
, watcher = require('./src/watcher')
;
// parse Argv
var argv = parseArgv(process.argv, aliases)
, commands = argv._
, commandString = commands.join('')
, args = argv
, firstCommand = commands[0]
, isNeedsHelp = commands.length === 0 || commandString.indexOf('help') !== -1
, isInstallOrUpdate = firstCommand === 'install' || firstCommand === 'update'
, isAliasCommand = firstCommand === 'alias' || firstCommand === 'aliases'
;
// remove commands from arguments;
delete args._;
if (isNeedsHelp) {
help();
} else if (isInstallOrUpdate) {
processInstallCommands(commands, args);
} else if (isAliasCommand) {
processAliasCommands(commands, args);
} else {
if (args.watch) {
watcher(commands, args);
} else {
// check for docker option
if (args.docker) {
// process commands from within the application's docker container
processCommandsInContainer(commands, args);
} else {
// process commands locally
processCommands(commands, args);
}
}
}