UNPKG

1.7 kBJavaScriptView Raw
1"use strict";
2
3var _config = require("./config");
4
5function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
7function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _next(value) { step("next", value); } function _throw(err) { step("throw", err); } _next(); }); }; }
8
9const L = require('lodash');
10
11const fs = require('fs-extra');
12
13const path = require('path');
14
15const resolver = new _config.ConfigResolver('.hygen.js', {
16 exists: fs.exists,
17 load: f => Promise.resolve(require(f))
18});
19
20module.exports =
21/*#__PURE__*/
22function () {
23 var _ref = _asyncToGenerator(function* (config) {
24 const cwd = config.cwd,
25 templates = config.templates;
26 const start = new Date();
27 const fileConfig = yield resolver.resolve(cwd);
28 console.log('timing:', new Date() - start);
29 const resolvedTemplates = L.find([// $FlowFixMe
30 process.env.HYGEN_TMPLS, path.join(cwd, '_templates')], _ => fs.existsSync(_)) || templates;
31 return _extends({}, config, {
32 templates: resolvedTemplates
33 }, fileConfig);
34 });
35
36 return function (_x) {
37 return _ref.apply(this, arguments);
38 };
39}();
\No newline at end of file