1 | 'use strict';
|
2 |
|
3 | var fs = require('fs-extra'),
|
4 | path = require('path'),
|
5 | glob = require('glob'),
|
6 | mainBowerFiles = require('main-bower-files');
|
7 |
|
8 | function is_file(fullpath) {
|
9 | return fs.existsSync(fullpath) && fs.statSync(fullpath).isFile();
|
10 | }
|
11 |
|
12 | module.exports = function(options) {
|
13 | var bower_dir = path.resolve(options.paths.bower, 'bower_components');
|
14 |
|
15 | return function(done) {
|
16 | glob.sync(path.join(bower_dir, 'rainbow-ui-*'))
|
17 | .forEach(function(addon_dir) {
|
18 | var data = fs.readJsonSync(path.join(addon_dir, 'bower.json')),
|
19 | files = Array.isArray(data.main) ? data.main : [data.main];
|
20 |
|
21 | files.forEach(function(filter) {
|
22 | glob.sync(path.resolve(addon_dir, filter)).forEach(function(file) {
|
23 | fs.copySync(file, path.resolve(bower_dir, 'semantic-ui', path.relative(addon_dir, file)));
|
24 | });
|
25 | });
|
26 | });
|
27 |
|
28 | mainBowerFiles({
|
29 | paths: {
|
30 | bowerDirectory: path.relative(process.cwd(), bower_dir),
|
31 | bowerJson: path.join(options.paths.bower, 'bower.json')
|
32 | }
|
33 | }).forEach(function(src) {
|
34 | if (is_file(src)) {
|
35 | fs.copySync(src, path.join(options.paths.dest, options.paths.vendor, path.relative(bower_dir, src)));
|
36 | }
|
37 | });
|
38 |
|
39 | done();
|
40 | };
|
41 | };
|