Skip to content

Commit

Permalink
getDir: test indicates file contents are buffer (#56)
Browse files Browse the repository at this point in the history
* getDir tests, use os.EOL for comparison
  • Loading branch information
msimerson committed Nov 25, 2019
1 parent 84cf659 commit 8e32ce5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ windows-latest ]
node-version: [8.x, 10.x, 12.x]
node-version: [10.x, 12.x]
fail-fast: false

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [8.x, 10.x, 12.x]
node-version: [10.x, 12.x]
fail-fast: false

steps:
Expand Down
2 changes: 1 addition & 1 deletion readers/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.load = (name) => {
}

exports.loadPromise = (name) => {
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
fs.readFile(name, (err, content) => {
if (err) return reject(err);
resolve({ path: name, data: content });
Expand Down
2 changes: 1 addition & 1 deletion readers/flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports.load = (name, type, options, regex) => {
return result;
}

exports.empty = function (options, type) {
exports.empty = (options, type) => {
switch (type) {
case 'flat':
case 'value':
Expand Down
14 changes: 8 additions & 6 deletions test/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

const assert = require('assert')
const fs = require('fs');
const path = require('path');
const fs = require('fs')
const os = require('os')
const path = require('path')

function cb () { return false; }
const opts = { booleans: ['arg1'] };
Expand Down Expand Up @@ -464,11 +465,12 @@ describe('getDir', function () {

it('loads all files in dir', function (done) {
this.config.getDir('dir', { type: 'binary' }, (err, files) => {
assert.ifError(err);
// console.log(files);
assert.equal(err, null);
assert.equal(files.length, 3);
assert.equal(files[0].data, 'contents1\n');
assert.equal(files[2].data, 'contents3\n');
assert.equal(files[0].data, `contents1${os.EOL}`);
assert.equal(files[2].data, `contents3${os.EOL}`);
done();
})
})
Expand Down Expand Up @@ -498,8 +500,8 @@ describe('getDir', function () {
// console.log(files);
assert.equal(err, null);
assert.equal(files.length, 3);
assert.equal(files[0].data, 'contents1\n');
assert.equal(files[2].data, 'contents3\n');
assert.equal(files[0].data, `contents1${os.EOL}`);
assert.equal(files[2].data, `contents3${os.EOL}`);
fs.writeFile(tmpFile, 'contents4\n', (err2, res) => {
assert.equal(err2, null);
// console.log('file touched, waiting for callback');
Expand Down

0 comments on commit 8e32ce5

Please sign in to comment.