Skip to content

Commit

Permalink
refactor: use custom EOL for cross platform
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Mar 28, 2017
1 parent c384452 commit cf6f99c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/EOL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict'

module.exports = /\r\n|\r|\n/g
4 changes: 2 additions & 2 deletions src/Ast/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

const _ = require('lodash')
const os = require('os')
const EOL = require('../../lib/EOL')
const CE = require('../Exceptions')

/**
Expand Down Expand Up @@ -195,7 +195,7 @@ class Ast {
this
._template
.trim()
.split(os.EOL)
.split(EOL)
.forEach((line, index) => {
/**
* Do not process anything when inside the block
Expand Down
6 changes: 3 additions & 3 deletions src/Buffer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

const os = require('os')
const EOL = require('../../lib/EOL')
const identString = require('indent-string')

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ class Buffer {
* @return {String}
*/
get EOL () {
return os.EOL
return EOL
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ class Buffer {
*/
getLines () {
const lines = this._lines.concat(this._getEndLines())
return lines.join(os.EOL)
return lines.join('\n')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Tags/LayoutTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class LayoutTag extends BaseTag {
inheritParent = true
}

const sectionOutput = childs.map((child) => compiler.parseAndReturnLine(child)).join(buffer.EOL)
const sectionOutput = childs.map((child) => compiler.parseAndReturnLine(child)).join('\n')

/**
* Store the output of section inside a key on the
Expand Down
2 changes: 1 addition & 1 deletion test/functional/conditionals/test.async.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ test.group('Functional | Conditionals', (group) => {
const $ = cheerio.load(browser.html())
const error = JSON.parse($('body').text())
assert.equal(error.name, 'InvalidExpressionException')
assert.equal(error.stack.split('\n')[1].trim(), `at (${viewsPath}/error-if-else.edge:9:0)`)
assert.equal(error.stack.split('\n')[1].trim(), `at (${path.join(viewsPath, 'error-if-else.edge')}:9:0)`)
})
})

0 comments on commit cf6f99c

Please sign in to comment.