1
1
/* jshint node: true */
2
2
'use strict' ;
3
3
4
- var chalk = require ( 'chalk' ) ;
4
+ var Promise = require ( 'ember-cli/lib/ext/promise' ) ;
5
+
5
6
var glob = require ( 'glob' ) ;
7
+ var chalk = require ( 'chalk' ) ;
8
+ var blue = chalk . blue ;
6
9
7
10
module . exports = {
8
11
name : 'ember-cli-deploy-build' ,
9
12
10
13
createDeployPlugin : function ( options ) {
11
- function pipelineData ( outputPath ) {
12
- var data = { } ;
14
+ function _beginMessage ( ui , outputPath ) {
15
+ ui . write ( blue ( '| ' ) ) ;
16
+ ui . writeLine ( blue ( '- building into `' + outputPath + '`' ) ) ;
13
17
14
- var files = glob . sync ( outputPath + '/index.html' , { nonull : false } ) ;
15
-
16
- if ( files && files . length ) {
17
- data . indexPath = files [ 0 ] ;
18
- }
18
+ return Promise . resolve ( ) ;
19
+ }
19
20
20
- files = glob . sync ( outputPath + '**/**/*' , { nonull : false , ignore : '**/index.html' } ) ;
21
+ function _successMessages ( ui , outputPath ) {
22
+ var files = glob . sync ( outputPath + '**/**/*' , { nonull : false , nodir : true } ) ;
21
23
22
24
if ( files && files . length ) {
23
- data . assetPaths = files ;
25
+ files . forEach ( function ( path ) {
26
+ ui . write ( blue ( '| ' ) ) ;
27
+ ui . writeLine ( blue ( '- ' + path ) ) ;
28
+ } ) ;
24
29
}
25
30
26
- return data ;
31
+ ui . write ( blue ( '| ' ) ) ;
32
+ ui . writeLine ( blue ( '- build successful' ) ) ;
33
+
34
+ return Promise . resolve ( files ) ;
27
35
}
28
36
29
37
return {
@@ -38,8 +46,6 @@ module.exports = {
38
46
var outputPath = 'dist' ;
39
47
var buildEnv = config . buildEnv || 'production' ;
40
48
41
- ui . startProgress ( chalk . green ( 'Building' ) , chalk . green ( '.' ) ) ;
42
-
43
49
var Builder = require ( 'ember-cli/lib/models/builder' ) ;
44
50
var builder = new Builder ( {
45
51
ui : ui ,
@@ -48,21 +54,25 @@ module.exports = {
48
54
project : project
49
55
} ) ;
50
56
51
- return builder . build ( )
57
+ return _beginMessage ( ui , outputPath )
58
+ . then ( builder . build . bind ( builder ) )
52
59
. finally ( function ( ) {
53
- ui . stopProgress ( ) ;
54
60
return builder . cleanup ( ) ;
55
61
} )
56
- . then ( function ( ) {
57
- ui . writeLine ( chalk . green ( 'Built project successfully. Stored in "' +
58
- outputPath + '".' ) ) ;
62
+ . then ( _successMessages . bind ( this , ui , outputPath ) )
63
+ . then ( function ( files ) {
64
+ files = files || [ ] ;
65
+
66
+ return {
67
+ distDir : outputPath ,
68
+ distFiles : files
69
+ } ;
59
70
} )
60
- . then ( pipelineData . bind ( this , outputPath ) )
61
- . catch ( function ( err ) {
62
- ui . writeLine ( chalk . red ( 'Build failed.' ) ) ;
63
- ui . writeError ( err ) ;
71
+ . catch ( function ( error ) {
72
+ ui . write ( blue ( '| ' ) ) ;
73
+ ui . writeLine ( chalk . red ( 'build failed' ) ) ;
64
74
65
- return 1 ;
75
+ return Promise . reject ( error ) ;
66
76
} ) ;
67
77
}
68
78
}
0 commit comments