Skip to content

Commit 2d9b857

Browse files
committed
adds src and filename options
1 parent d577e70 commit 2d9b857

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

index.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,24 @@ function generateQrc(path) {
7878
});
7979
}
8080

81-
module.exports = function() {
81+
module.exports = function(options) {
8282
function modifyFile(file, encoding, callback) {
83-
if (file.isNull()) return this.emit('data', file);
83+
if (file.isNull()) return this.emit("data", file);
8484
if (file.isStream()) return this.emit('error', new Error("gulp-qml: Streaming not supported"));
85+
if (!options) options = {};
8586

8687
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}};";
8991

9092
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);
9496
callback();
9597
}).catch(function(error) {
96-
self.emit('error', new Error(file.path + ': ' + error));
98+
self.emit("error", new Error(file.path + ": " + error));
9799
callback();
98100
});
99101
}

0 commit comments

Comments
 (0)