-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathelasticio
More file actions
executable file
·45 lines (38 loc) · 1.74 KB
/
Copy pathelasticio
File metadata and controls
executable file
·45 lines (38 loc) · 1.74 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
#!/usr/bin/env node
const program = require('caporal');
const fs = require('fs');
const { runProcess } = require('./lib/executables/process');
const { runExec } = require('./lib/executables/exec');
const { runValidate } = require('./lib/executables/validate');
const { version } = JSON.parse(fs.readFileSync(`${__dirname}/package.json`, 'utf8'));
program
.version(version);
program
.command('cmp:process', 'Run the startup, init, process, and shutdown function of an action/trigger. Only the process is mandatory')
.argument('[path]', 'Path to component folder, defaults to current directory', null, process.cwd())
.option('-x, --fixture [fixture]', 'Fixture to run against')
.option('-a, --action [action]', 'Name of action/trigger to run')
.action(async (args, options) => {
const { fixture, action } = options;
const { path } = args;
await runProcess(path, fixture, action);
});
program
.command('cmp:exec', 'Run any exposed function from a file, including verifyCredentials')
.argument('[path]', 'Path to component folder, defaults to current directory', null, process.cwd())
.option('-x, --fixture [fixture]', 'Fixture to run against')
.option('-f, --function [func]', 'Function name to run')
.option('-a, --action [action]', 'Name of action/trigger to run')
.action(async (args, options) => {
const { fixture, action } = options;
const func = options.function;
const { path } = args;
await runExec(path, func, fixture, action);
});
program
.command('cmp:validate', 'Validate component.json, action/trigger files, and any static schemas')
.argument('[path]', 'Path to component folder', null, process.cwd())
.action(async (args) => {
await runValidate(args.path);
});
program.parse(process.argv);