@@ -21,22 +21,22 @@ module.exports = {
2121 name : 'ember-cli-deploy-json-config' ,
2222
2323 createDeployPlugin : function ( options ) {
24- function _beginMessage ( ui , inputPattern , outputPattern ) {
25- ui . write ( blue ( '| ' ) ) ;
26- ui . writeLine ( blue ( '- generating `' + outputPattern + '` from `' + inputPattern + '`' ) ) ;
24+ function _beginMessage ( ui , inputPath , outputPath ) {
25+ ui . write ( blue ( '| ' ) ) ;
26+ ui . writeLine ( blue ( '- generating `' + outputPath + '` from `' + inputPath + '`' ) ) ;
2727
2828 return Promise . resolve ( ) ;
2929 }
3030
31- function _successMessage ( ui , outputPattern ) {
32- ui . write ( blue ( '| ' ) ) ;
33- ui . writeLine ( blue ( '- generated: `' + outputPattern + '`' ) ) ;
31+ function _successMessage ( ui , outputPath ) {
32+ ui . write ( blue ( '| ' ) ) ;
33+ ui . writeLine ( blue ( '- generated: `' + outputPath + '`' ) ) ;
3434
35- return Promise . resolve ( outputPattern ) ;
35+ return Promise . resolve ( ) ;
3636 }
3737
3838 function _errorMessage ( ui , error ) {
39- ui . write ( blue ( '| ' ) ) ;
39+ ui . write ( blue ( '| ' ) ) ;
4040 ui . write ( red ( '- ' + error + '`\n' ) ) ;
4141
4242 return Promise . reject ( error ) ;
@@ -62,20 +62,26 @@ module.exports = {
6262 var ui = deployment . ui ;
6363 var config = deployment . config [ this . name ] ;
6464 var project = deployment . project ;
65- var root = project . root ;
66-
67- var fileInputPattern = config . fileInputPattern ;
68- var fileOutputPattern = config . fileOutputPattern ;
69- var inputPath = path . join ( root , fileInputPattern ) ;
70- var outputPath = path . join ( root , fileOutputPattern ) ;
7165
72- return _beginMessage ( ui , fileInputPattern , fileOutputPattern )
73- . then ( readFile . bind ( readFile , inputPath ) )
66+ var root = project . root ;
67+ var distDir = context . distDir ;
68+ var fileInputPattern = config . fileInputPattern ;
69+ var fileOutputPattern = config . fileOutputPattern ;
70+ var inputPath = path . join ( distDir , fileInputPattern ) ;
71+ var outputPath = path . join ( distDir , fileOutputPattern ) ;
72+ var absoluteInputPath = path . join ( root , inputPath ) ;
73+ var absoluteOutputPath = path . join ( root , outputPath ) ;
74+
75+ return _beginMessage ( ui , inputPath , outputPath )
76+ . then ( readFile . bind ( readFile , absoluteInputPath ) )
7477 . then ( extractConfig . bind ( this ) )
75- . then ( writeFile . bind ( writeFile , outputPath ) )
76- . then ( _successMessage . bind ( this , ui , fileOutputPattern ) )
77- . then ( function ( outputPattern ) {
78- return { distFiles : [ outputPattern ] } ;
78+ . then ( writeFile . bind ( writeFile , absoluteOutputPath ) )
79+ . then ( _successMessage . bind ( this , ui , outputPath ) )
80+ . then ( function ( ) {
81+ ui . write ( blue ( '| ' ) ) ;
82+ ui . writeLine ( blue ( '- added `' + fileOutputPattern + '` to `context.distFiles`' ) ) ;
83+
84+ return { distFiles : [ fileOutputPattern ] } ;
7985 } )
8086 . catch ( _errorMessage . bind ( this , ui ) ) ;
8187 }
0 commit comments