Files
noVNC/utils/make-module-transform.js
Solly Ross ae510306b5 Enable noVNC to become Browserifiable
This commit restructures noVNC, splitting it into the core directory
and the app directory, with the former containing core noVNC parts,
and the latter containing parts specific to the application.
2016-09-16 15:49:51 -04:00

26 lines
737 B
JavaScript

var through = require('through2');
var singleLineRe = /\/\* \[module\] ((.(?!\*\/))+) \*\//g;
var multiLineRe = /\/\* \[module\]\n(( * .+\n)+) \*\//g;
var skipAsModule = /\/\* \[begin skip-as-module\] \*\/(.|\n)+\/\* \[end skip-as-module\] \*\//g;
module.exports = function (file) {
var stream = through(function (buf, enc, next) {
var bufStr = buf.toString('utf8');
bufStr = bufStr.replace(singleLineRe, "$1");
bufStr = bufStr.replace(multiLineRe, function (match, mainLines) {
return mainLines.split(" * ").join("");
});
bufStr = bufStr.replace(skipAsModule, "");
this.push(bufStr);
next();
});
stream._is_make_module = true;
return stream;
};