UNPKG

908 BJavaScriptView Raw
1'use strict';
2
3var path = require('path');
4var fs = require('fs');
5const chalk = require('chalk')
6
7module.exports = function (source) {
8 this.cacheable(false);
9
10 try{
11 var appPath = path.resolve('src/model');
12 var src = fs.readdirSync(appPath).reduce(function (pre, next, index) {
13 if (index === 1) {
14 return 'rluy.model(require(\'./model/' + pre.split('.')[0] + '\'));\n' + ('rluy.model(require(\'./model/' + next.split('.')[0] + '\'));\n');
15 }
16 return pre + ('rluy.model(require(\'./model/' + next.split('.')[0] + '\'));\n');
17 });
18 this.addContextDependency(appPath);
19
20 console.log(chalk.green('adding module...'));
21 }catch(e){
22 console.log(chalk.red('please create a module folder in `{your app}/src/`'));
23 throw e
24 }
25
26 return source + '\n' + src + '\nexport const Rluy = rluy';
27};
\No newline at end of file