1
+ 'use strict' ;
2
+
3
+ var path = require ( 'path' ) ;
4
+ var Command = require ( 'ember-cli/lib/models/command' ) ;
5
+ var win = require ( 'ember-cli/lib/utilities/windows-admin' ) ;
6
+ var BuildCommand = require ( 'ember-cli/lib/commands/build' ) ;
7
+ var BuildTask = require ( 'ember-cli/lib/tasks/build' ) ;
8
+ var BuildWatchTask = require ( 'ember-cli/lib/tasks/build-watch' ) ;
9
+ var TestTask = require ( '../tasks/test' ) ;
10
+
11
+ module . exports = BuildCommand . extend ( {
12
+ name : 'build' ,
13
+ description : 'Builds your app and places it into the output path (dist/ by default).' ,
14
+ aliases : [ 'b' ] ,
15
+
16
+ availableOptions : [
17
+ { name : 'environment' , type : String , default : 'development' , aliases : [ 'e' , { 'dev' : 'development' } , { 'prod' : 'production' } ] } ,
18
+ { name : 'output-path' , type : path , default : 'dist/' , aliases : [ 'o' ] } ,
19
+ { name : 'watch' , type : Boolean , default : false , aliases : [ 'w' ] } ,
20
+ { name : 'watcher' , type : String } ,
21
+ { name : 'no-test' , type : Boolean , default : false }
22
+ ] ,
23
+
24
+ run : function ( commandOptions ) {
25
+ var BuildTask = this . tasks . Build ;
26
+ var buildTask = new BuildTask ( {
27
+ ui : this . ui ,
28
+ analytics : this . analytics ,
29
+ project : this . project
30
+ } ) ;
31
+ var BuildWatchTask = this . tasks . BuildWatch ;
32
+ var buildWatchTask = new BuildWatchTask ( {
33
+ ui : this . ui ,
34
+ analytics : this . analytics ,
35
+ project : this . project
36
+ } ) ;
37
+ var testTask = new TestTask ( {
38
+ ui : this . ui ,
39
+ analytics : this . analytics ,
40
+ project : this . project
41
+ } ) ;
42
+
43
+ if ( commandOptions . watch ) {
44
+ return win . checkWindowsElevation ( this . ui )
45
+ . then ( function ( ) {
46
+ commandOptions . buildCompleted = function ( ) {
47
+ return testTask . run ( { singleRun : true } ) ;
48
+ } ;
49
+ return buildWatchTask . run ( commandOptions ) ;
50
+ } ) ;
51
+ } else {
52
+ return win . checkWindowsElevation ( this . ui )
53
+ . then ( function ( ) {
54
+ commandOptions . buildCompleted = function ( ) {
55
+ return testTask . run ( { singleRun : true } ) ;
56
+ } ;
57
+ return buildTask . run ( commandOptions ) ;
58
+ } ) ;
59
+ }
60
+ }
61
+ } ) ;
62
+
63
+ module . exports . overrideCore = true ;
0 commit comments