1 | 'use strict';
|
2 |
|
3 | var path = require('path');
|
4 | var fs = require('fs');
|
5 | const chalk = require('chalk')
|
6 |
|
7 | module.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 |