@@ -8,63 +8,66 @@ const SilentError = require('silent-error');
88const blockForever = ( ) => ( new RSVP . Promise ( ( ) => { } ) ) ;
99const noop = function ( ) { } ;
1010
11- module . exports = {
12- name : 'fastboot' ,
13- description : 'Builds and serves your FastBoot app, rebuilding on file changes.' ,
11+ module . exports = function ( addon ) {
12+ return {
13+ name : 'fastboot' ,
14+ description : 'Builds and serves your FastBoot app, rebuilding on file changes.' ,
1415
15- availableOptions : [
16- { name : 'build' , type : Boolean , default : true } ,
17- { name : 'watch' , type : Boolean , default : true , aliases : [ 'w' ] } ,
18- { name : 'environment' , type : String , default : 'development' , aliases : [ 'e' , { 'dev' : 'development' } , { 'prod' : 'production' } ] } ,
19- { name : 'serve-assets' , type : Boolean , default : false } ,
20- { name : 'host' , type : String , default : '::' } ,
21- { name : 'port' , type : Number , default : 3000 } ,
22- { name : 'output-path' , type : String , default : 'dist' } ,
23- { name : 'assets-path' , type : String , default : 'dist' }
24- ] ,
16+ availableOptions : [
17+ { name : 'build' , type : Boolean , default : true } ,
18+ { name : 'watch' , type : Boolean , default : true , aliases : [ 'w' ] } ,
19+ { name : 'environment' , type : String , default : 'development' , aliases : [ 'e' , { 'dev' : 'development' } , { 'prod' : 'production' } ] } ,
20+ { name : 'serve-assets' , type : Boolean , default : false } ,
21+ { name : 'host' , type : String , default : '::' } ,
22+ { name : 'port' , type : Number , default : 3000 } ,
23+ { name : 'output-path' , type : String , default : 'dist' } ,
24+ { name : 'assets-path' , type : String , default : 'dist' }
25+ ] ,
2526
26- blockForever,
27- getPort,
28- ServerTask,
27+ blockForever,
28+ getPort,
29+ ServerTask,
2930
30- run ( options ) {
31- const runBuild = ( ) => this . runBuild ( options ) ;
32- const runServer = ( ) => this . runServer ( options ) ;
33- const blockForever = this . blockForever ;
31+ run ( options ) {
32+ const runBuild = ( ) => this . runBuild ( options ) ;
33+ const runServer = ( ) => this . runServer ( options ) ;
34+ const blockForever = this . blockForever ;
3435
35- return this . checkPort ( options )
36- . then ( runServer ) // starts on postBuild SIGHUP
37- . then ( options . build ? runBuild : noop )
38- . then ( blockForever ) ;
39- } ,
36+ return this . checkPort ( options )
37+ . then ( runServer ) // starts on postBuild SIGHUP
38+ . then ( options . build ? runBuild : noop )
39+ . then ( blockForever ) ;
40+ } ,
4041
41- runServer ( options ) {
42- const ServerTask = this . ServerTask ;
43- const serverTask = new ServerTask ( {
44- ui : this . ui ,
45- } ) ;
46- return serverTask . run ( options ) ;
47- } ,
48-
49- runBuild ( options ) {
50- const BuildTask = options . watch ? this . tasks . BuildWatch : this . tasks . Build ;
51- const buildTask = new BuildTask ( {
52- ui : this . ui ,
53- analytics : this . analytics ,
54- project : this . project ,
55- } ) ;
56- buildTask . run ( options ) ; // no return, BuildWatch.run blocks forever
57- } ,
42+ runServer ( options ) {
43+ const ServerTask = this . ServerTask ;
44+ const serverTask = new ServerTask ( {
45+ ui : this . ui ,
46+ addon : addon
47+ } ) ;
48+ return serverTask . run ( options ) ;
49+ } ,
5850
59- checkPort ( options ) {
60- return this . getPort ( { port : options . port , host : options . host } )
61- . then ( ( foundPort ) => {
62- if ( options . port !== foundPort && options . port !== 0 ) {
63- const message = `Port ${ options . port } is already in use.` ;
64- return Promise . reject ( new SilentError ( message ) ) ;
65- }
66- options . port = foundPort ;
51+ runBuild ( options ) {
52+ const BuildTask = options . watch ? this . tasks . BuildWatch : this . tasks . Build ;
53+ const buildTask = new BuildTask ( {
54+ ui : this . ui ,
55+ analytics : this . analytics ,
56+ project : this . project ,
6757 } ) ;
68- } ,
58+ buildTask . run ( options ) ; // no return, BuildWatch.run blocks forever
59+ } ,
60+
61+ checkPort ( options ) {
62+ return this . getPort ( { port : options . port , host : options . host } )
63+ . then ( ( foundPort ) => {
64+ if ( options . port !== foundPort && options . port !== 0 ) {
65+ const message = `Port ${ options . port } is already in use.` ;
66+ return Promise . reject ( new SilentError ( message ) ) ;
67+ }
68+ options . port = foundPort ;
69+ } ) ;
70+ } ,
6971
72+ }
7073} ;
0 commit comments