Skip to content

Commit

Permalink
Crossplatform work. Fixes svg#538
Browse files Browse the repository at this point in the history
  • Loading branch information
GreLI committed Aug 20, 2016
1 parent 815f5cf commit e4003b4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: node_js

node_js:
- 0.10
- 0.12
- 4
- 6

branches:
only:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test:
@NODE_ENV=test ./node_modules/.bin/mocha
@npm run test

lib-cov:
@./node_modules/.bin/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib
Expand All @@ -16,6 +16,6 @@ coveralls: lib-cov
travis: jshint test coveralls

jshint:
@jshint --show-non-errors .
@npm run jshint

.PHONY: test
21 changes: 11 additions & 10 deletions lib/svgo/js2svg.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var EXTEND = require('whet.extend'),
var EOL = require('os').EOL,
EXTEND = require('whet.extend'),
textElem = require('../../plugins/_collections.js').elemsGroups.textContent.concat('title');

var defaults = {
Expand Down Expand Up @@ -69,14 +70,14 @@ function JS2SVG(config) {
}

if (this.config.pretty) {
this.config.doctypeEnd += '\n';
this.config.procInstEnd += '\n';
this.config.commentEnd += '\n';
this.config.cdataEnd += '\n';
this.config.tagShortEnd += '\n';
this.config.tagOpenEnd += '\n';
this.config.tagCloseEnd += '\n';
this.config.textEnd += '\n';
this.config.doctypeEnd += EOL;
this.config.procInstEnd += EOL;
this.config.commentEnd += EOL;
this.config.cdataEnd += EOL;
this.config.tagShortEnd += EOL;
this.config.tagOpenEnd += EOL;
this.config.tagCloseEnd += EOL;
this.config.textEnd += EOL;
}

this.indentLevel = 0;
Expand Down Expand Up @@ -282,7 +283,7 @@ JS2SVG.prototype.createElem = function(data) {

if (this.textContext == data) {
this.textContext = null;
if (this.config.pretty) dataEnd = '\n';
if (this.config.pretty) dataEnd = EOL;
}

return openIndent +
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"example": "./examples"
},
"scripts": {
"test": "make test"
"test": "set NODE_ENV=test && mocha",
"jshint": "jshint --show-non-errors ."
},
"dependencies": {
"sax": "~1.2.1",
Expand Down
4 changes: 2 additions & 2 deletions plugins/cleanupAttrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ exports.params = {
spaces: true
};

var regNewlinesNeedSpace = /(\S)\n(\S)/g,
regNewlines = /\n/g,
var regNewlinesNeedSpace = /(\S)\r?\n(\S)/g,
regNewlines = /\r?\n/g,
regSpaces = /\s{2,}/g;

/**
Expand Down

0 comments on commit e4003b4

Please sign in to comment.