1 | const engine = require("./lib/engine");
|
2 | const { file, anyfile } = require("./lib/targets/file");
|
3 | const { virt, anyvirt } = require("./lib/targets/virtual");
|
4 |
|
5 | const argv = require("yargs").argv;
|
6 |
|
7 | exports._bddy = function() {
|
8 | return new engine.Context();
|
9 | };
|
10 | exports.file = file;
|
11 | exports.virt = virt;
|
12 | exports.any = {
|
13 | file: anyfile,
|
14 | virt: anyvirt
|
15 | };
|
16 | exports.argv = argv;
|
17 |
|
18 |
|
19 | const existingFile = require("./lib/predefs/existingFile");
|
20 | const Command = require("./lib/plugins/command");
|
21 | const Dir = require("./lib/plugins/dir");
|
22 |
|
23 | exports.bddy = function(defs) {
|
24 | let r = new engine.Context();
|
25 | r.loadDefinitions(existingFile);
|
26 | r.loadPlugin({ command: new Command(), dir: new Dir() });
|
27 | if (defs) {
|
28 | defs.call(r, r, (...a) => r.def(...a));
|
29 | }
|
30 | return r;
|
31 | };
|
32 |
|
33 | exports.build = async function(defs) {
|
34 | const bddy = exports.bddy(defs);
|
35 | if (argv._.length) {
|
36 | for (let wish of argv._) {
|
37 | await bddy.wish(wish);
|
38 | }
|
39 | } else {
|
40 | await bddy.wish("start");
|
41 | }
|
42 | };
|