@@ -78,22 +78,24 @@ function generateQrc(path) {
78
78
} ) ;
79
79
}
80
80
81
- module . exports = function ( ) {
81
+ module . exports = function ( options ) {
82
82
function modifyFile ( file , encoding , callback ) {
83
- if ( file . isNull ( ) ) return this . emit ( ' data' , file ) ;
83
+ if ( file . isNull ( ) ) return this . emit ( " data" , file ) ;
84
84
if ( file . isStream ( ) ) return this . emit ( 'error' , new Error ( "gulp-qml: Streaming not supported" ) ) ;
85
+ if ( ! options ) options = { } ;
85
86
86
87
var self = this ;
87
- var directory = file . path . split ( '/' ) . slice ( 0 , - 1 ) . join ( '/' ) ;
88
- var str = file . contents . toString ( 'utf8' ) ;
88
+ var directory = file . path . split ( "/" ) . slice ( 0 , - 1 ) . join ( "/" ) ;
89
+ var str = file . contents . toString ( "utf8" ) ;
90
+ var src = options . src || "QmlWeb.qrc = {{object}};" ;
89
91
90
92
return generateQrcFromString ( str , directory ) . then ( function ( result ) {
91
- file . contents = Buffer . from ( "QmlWeb.qrc=" + result + ';' ) ;
92
- file . path = "qrc.js" ;
93
- self . emit ( ' data' , file ) ;
93
+ file . contents = Buffer . from ( src . replace ( "{{object}}" , result ) ) ;
94
+ file . path = options . filename || "qrc.js" ;
95
+ self . emit ( " data" , file ) ;
94
96
callback ( ) ;
95
97
} ) . catch ( function ( error ) {
96
- self . emit ( ' error' , new Error ( file . path + ': ' + error ) ) ;
98
+ self . emit ( " error" , new Error ( file . path + ": " + error ) ) ;
97
99
callback ( ) ;
98
100
} ) ;
99
101
}
0 commit comments