Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added full windows support with tests.

* Patched yaml.js to support CRLF line endings.
  • Loading branch information...
commit a66274a3c1841ccaf13b46d7e5f6879735b9ef50 1 parent f0dd492
@jakubpawlowicz authored
Showing with 9 additions and 4 deletions.
  1. +2 −0  .gitattributes
  2. +1 −1  lib/assets.js
  3. +1 −0  test.bat
  4. +5 −3 vendor/yaml.js
View
2  .gitattributes
@@ -0,0 +1,2 @@
+* text=auto
+*.yml text
View
2  lib/assets.js
@@ -7,7 +7,7 @@ var AssetsExpander = function(pathToYaml, options) {
if (!pathToYaml) return;
try {
- this.yamlSource = yaml.eval(fs.readFileSync(pathToYaml).toString());
+ this.yamlSource = yaml.eval(fs.readFileSync(pathToYaml, 'utf-8'));
} catch (e) {
throw new AssetsExpander.YamlSyntaxError(e.toString());
}
View
1  test.bat
@@ -0,0 +1 @@
+node .\node_modules\vows\bin\vows test\assets-test.js
View
8 vendor/yaml.js
@@ -9,6 +9,8 @@ exports.version = '0.1.1'
// --- Helpers
+var isWindows = process.platform == 'win32';
+
/**
* Return 'near "context"' where context
* is replaced by a chunk of _str_.
@@ -22,7 +24,7 @@ function context(str) {
if (typeof str !== 'string') return ''
str = str
.slice(0, 25)
- .replace(/\n/g, '\\n')
+ .replace(isWindows ? /\r\n/g : /\n/g, '\\n')
.replace(/"/g, '\\\"')
return 'near "' + str + '"'
}
@@ -35,9 +37,9 @@ function context(str) {
var tokens = [
['comment', /^#[^\n]*/],
- ['indent', /^\n( *)/],
+ ['indent', isWindows ? /^\r\n( *)/ : /^\n( *)/],
['space', /^ +/],
- ['empty', /^\n$/],
+ ['empty', isWindows ? /^\r\n$/ : /^\n$/],
['true', /^(enabled|true|yes|on)/],
['false', /^(disabled|false|no|off)/],
['string', /^"(.*?)"/],
Please sign in to comment.
Something went wrong with that request. Please try again.