Skip to content

Commit ee77b12

Browse files
committed
Bassics of copy staticDist wroking
1 parent b256118 commit ee77b12

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

site/default/static/build.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,56 @@
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);
67

78
module.exports = function(options, folders){
8-
99
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(){
1111
return fsx.exists(path.join(folders.build,name)).then(function(exists){
1212
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));
1414
}
1515
});
1616
});
1717
};
1818

1919
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+
}
2325

2426
if(options.devBuild) {
2527
// copy all dependencies
2628
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))
2830
].concat(staticDistPromises));
2931
// copy everything and steal.js
3032
return promise;
3133
} else {
3234

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
4444
}).then(function(){
4545
if(options.debug) {
4646
console.log("BUILD: Copying build to dist.");
4747
}
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;
4954
});
5055
}
5156
};

0 commit comments

Comments
 (0)