|
1 |
| -var stealTools = require("steal-tools"), |
2 |
| - fsx = require('../../../../fs_extras'), |
3 |
| - Q = require('q'), |
4 |
| - path = require("path"); |
5 |
| - |
| 1 | +var stealTools = require("steal-tools"); |
| 2 | +var fsExtra = require('fs-extra'); |
| 3 | +var fsx = require('../../../../fs_extras'); |
| 4 | +var Q = require('q'); |
| 5 | +var path = require("path"); |
| 6 | +var copy = Q.denodeify(fsExtra.copy); |
6 | 7 |
|
7 | 8 | module.exports = function(options, folders){
|
8 |
| - |
9 | 9 | var copyDir = function(name){
|
10 |
| - return fsx.mkdirs( path.join(folders.dist,name) ).then(function(){ |
| 10 | + return fsx.mkdirs(path.join(folders.dist,name)).then(function(){ |
11 | 11 | return fsx.exists(path.join(folders.build,name)).then(function(exists){
|
12 | 12 | if(exists) {
|
13 |
| - return fsx.copy( path.join(folders.build,name), path.join(folders.dist,name) ); |
| 13 | + return fsx.copy(path.join(folders.build,name), path.join(folders.dist,name)); |
14 | 14 | }
|
15 | 15 | });
|
16 | 16 | });
|
17 | 17 | };
|
18 | 18 |
|
19 | 19 | var staticDistPromises = [];
|
20 |
| - options.html.staticDist.forEach(function(dist){ |
21 |
| - staticDistPromises.push(fsx.copy(dist, path.join(folders.dist))); |
22 |
| - }); |
| 20 | + if(options.html && options.html.staticDist){ |
| 21 | + options.html.staticDist.forEach(function(dist){ |
| 22 | + staticDistPromises.push(copy(path.join(process.cwd(), dist), folders.dist)); |
| 23 | + }); |
| 24 | + } |
23 | 25 |
|
24 | 26 | if(options.devBuild) {
|
25 | 27 | // copy all dependencies
|
26 | 28 | var promise = Q.all([
|
27 |
| - fsx.copy(path.join(folders.build), path.join(folders.dist) ) |
| 29 | + fsx.copy(path.join(folders.build), path.join(folders.dist)) |
28 | 30 | ].concat(staticDistPromises));
|
29 | 31 | // copy everything and steal.js
|
30 | 32 | return promise;
|
31 | 33 | } else {
|
32 | 34 |
|
33 |
| - Promise.all(staticDistPromises).then(function(){ |
34 |
| - // run steal-tools and then copy things |
35 |
| - return stealTools.build({ |
36 |
| - config: __dirname+"/package.json!npm", |
37 |
| - main: "bit-docs-site/static" |
38 |
| - },{ |
39 |
| - minify: options.minifyBuild === false ? false : true, |
40 |
| - quiet: options.debug ? false : true, |
41 |
| - debug: options.debug ? true : false, |
42 |
| - bundleAssets: true |
43 |
| - }); |
| 35 | + // run steal-tools and then copy things |
| 36 | + return stealTools.build({ |
| 37 | + config: __dirname+"/package.json!npm", |
| 38 | + main: "bit-docs-site/static" |
| 39 | + },{ |
| 40 | + minify: options.minifyBuild === false ? false : true, |
| 41 | + quiet: options.debug ? false : true, |
| 42 | + debug: options.debug ? true : false, |
| 43 | + bundleAssets: true |
44 | 44 | }).then(function(){
|
45 | 45 | if(options.debug) {
|
46 | 46 | console.log("BUILD: Copying build to dist.");
|
47 | 47 | }
|
48 |
| - return fsx.copy(path.join(folders.build, "dist"), path.join(folders.dist) ); |
| 48 | + |
| 49 | + var promise = Q.all([ |
| 50 | + fsx.copy(path.join(folders.build, "dist"), path.join(folders.dist)) |
| 51 | + ].concat(staticDistPromises)); |
| 52 | + |
| 53 | + return promise; |
49 | 54 | });
|
50 | 55 | }
|
51 | 56 | };
|
0 commit comments