test("plugins.load", co(function* (t) { // const out1 = yield plugs.load(join("/fake123", "taskfile.js")) // t.true(Array.isArray(out1) && out1.length === 0, "via invalid file returns an empty array") // ^^ logs error message to test disrupts formatting const out = yield plugs.load(taskfile) t.ok(Array.isArray(out), "returns an array") t.equal(out.length, 7, "filters down to fly|taskr plugins only") t.equal(typeof out[0], "function", "is an array of functions") t.equal(out[2], undefined, "returns `undefined` for faulty plugins") t.end() }))
co(function * (cwd) { const file = yield find("taskfile.js", cwd) if (!file) { return new Taskr() } // find & `require()`. will load `@taskr/esnext` before spawning const plugins = yield load(file) // spawn options const opts = {cwd, file, plugins} try { const esnext = require("@taskr/esnext") if (esnext) { const data = yield read(file, "utf8") opts.tasks = esnext(file, data) } } catch (err) {} return new Taskr(opts) })
co(function * (cwd) { const file = yield find("taskfile.js", cwd) if (!file) { return new Taskr() } // find & `require()`. will load `@taskr/esnext` before spawning const plugins = yield load(file) // spawn options const opts = {cwd, file, plugins} try { const esnext = require("@taskr/esnext") if (esnext) { const data = yield read(file, "utf8") opts.tasks = esnext(file, data) } } catch (err) {} return new Taskr(opts) })