UNPKG

1 kBJavaScriptView Raw
1const engine = require("./lib/engine");
2const { file, anyfile } = require("./lib/targets/file");
3const { virt, anyvirt } = require("./lib/targets/virtual");
4
5const argv = require("yargs").argv;
6
7exports._bddy = function() {
8 return new engine.Context();
9};
10exports.file = file;
11exports.virt = virt;
12exports.any = {
13 file: anyfile,
14 virt: anyvirt
15};
16exports.argv = argv;
17
18//predefs
19const existingFile = require("./lib/predefs/existingFile");
20const Command = require("./lib/plugins/command");
21const Dir = require("./lib/plugins/dir");
22
23exports.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
33exports.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};