Skip to content

Commit

Permalink
Corrected tests and scripts to remove \r\n and only use \n
Browse files Browse the repository at this point in the history
  • Loading branch information
intervalia committed Jan 3, 2015
1 parent 5ef7b3a commit af1b0dc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function processOneScript(scriptPath, includeName, options, newPluginParams) {

var contents = "/*\n * Included File: " + includeName + "\n */\n";
contents += plugin.processFilePre(newPluginParams);
contents += fs.readFileSync(scriptPath, {"encoding": "utf-8"});
contents += fs.readFileSync(scriptPath, {"encoding": "utf-8"}).replace(/\r\n/g, "\n");
contents += "\n";
contents += plugin.processFilePost(newPluginParams);

Expand Down
24 changes: 14 additions & 10 deletions test/specs/assemblies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ var fs = require('fs');
var gutil = require('gulp-util');
var should = require('should');

function readDataFile(path) {
return fs.readFileSync(path, {"encoding": "utf-8"}).replace(/\r/g, "");
}

describe('\n Testing the file assemblies.js', function () {
var rootPath;

Expand Down Expand Up @@ -84,7 +88,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub1.no-options.js", val);
temp = fs.readFileSync("./test/data/sub1.no-options.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub1.no-options.js");
val.should.equal(temp);
done();
});
Expand All @@ -95,7 +99,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub1.locale-fr.js", val);
temp = fs.readFileSync("./test/data/sub1.locale-fr.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub1.locale-fr.js");
val.should.equal(temp);
done();
});
Expand All @@ -107,7 +111,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub1.exposeLang.js", val);
temp = fs.readFileSync("./test/data/sub1.exposeLang.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub1.exposeLang.js");
val.should.equal(temp);
done();
});
Expand All @@ -119,7 +123,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub1.supportTransKeys.js", val);
temp = fs.readFileSync("./test/data/sub1.supportTransKeys.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub1.supportTransKeys.js");
val.should.equal(temp);
done();
});
Expand All @@ -131,7 +135,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub1.tagMissingStrings.js", val);
temp = fs.readFileSync("./test/data/sub1.tagMissingStrings.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub1.tagMissingStrings.js");
val.should.equal(temp);
done();
});
Expand All @@ -151,7 +155,7 @@ describe('\n Testing the file assemblies.js', function () {
beforeEach(function() {
projectPath = path.join(rootPath, "testdata/main/sub2");
assemblyFileName = path.join(projectPath, "assembly.json");
temp = fs.readFileSync(assemblyFileName, {"encoding": "utf-8"});
temp = readDataFile(assemblyFileName);
assembly = JSON.parse(temp);
});

Expand All @@ -161,7 +165,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub2.no-options.js", val);
temp = fs.readFileSync("./test/data/sub2.no-options.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub2.no-options.js");
val.should.equal(temp);
done();
});
Expand All @@ -173,7 +177,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub2.min-ws.js", val);
temp = fs.readFileSync("./test/data/sub2.min-ws.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub2.min-ws.js");
val.should.equal(temp);
done();
});
Expand All @@ -185,7 +189,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub2.useStrict.js", val);
temp = fs.readFileSync("./test/data/sub2.useStrict.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub2.useStrict.js");
val.should.equal(temp);
done();
});
Expand All @@ -200,7 +204,7 @@ describe('\n Testing the file assemblies.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub2.iifeParams.js", val);
temp = fs.readFileSync("./test/data/sub2.iifeParams.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub2.iifeParams.js");
val.should.equal(temp);
done();
});
Expand Down
12 changes: 5 additions & 7 deletions test/specs/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ var fs = require('fs');
var gutil = require('gulp-util');
var should = require('should');

function readDataFile(path) {
return fs.readFileSync(path, {"encoding": "utf-8"}).replace(/\r/g, "");
}

describe('\n Testing the file plugin.js', function () {
var rootPath;

Expand Down Expand Up @@ -200,17 +204,11 @@ describe('\n Testing the file plugin.js', function () {
};
var val = assemblies.process(assembly, assemblyFileName, options);
//fs.writeFileSync("./test/data/sub1.with-plugins.js", val);
temp = fs.readFileSync("./test/data/sub1.with-plugins.js", {"encoding": "utf-8"});
temp = readDataFile("./test/data/sub1.with-plugins.js");
val.should.equal(temp);

done();
});

});
});


/*
* processPre
* processPost
*/

0 comments on commit af1b0dc

Please sign in to comment.