control-freak-ide/server/nodejs/util/build/fs.js
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

24 lines
634 B
JavaScript

define(["dojo/has!host-node?./node/fs:./rhino/fs"], function(result){
// Code to strip BOM
var origReadFileSync = result.readFileSync;
result.readFileSync = function(filename, encoding) {
var text = origReadFileSync(filename, encoding);
if(encoding == "utf8"){
text = text.replace(/^\uFEFF/, ''); // remove BOM
}
return text;
};
var origReadFile = result.readFile;
result.readFile = function(filename, encoding, cb){
origReadFile(filename, encoding, function(err, text){
if(text && encoding == "utf8"){
text = text.replace(/^\uFEFF/, ''); // remove BOM
}
cb(err, text);
});
};
return result;
});