Permalink
Browse files

Removed deprecated `require` support

  • Loading branch information...
1 parent fa66a5b commit 549ae1ff1b1a6e0f10d7bc1f70288b5e3fd8d628 @puzrin puzrin committed Jun 16, 2014
View
@@ -1,15 +1,7 @@
'use strict';
-var fs = require('fs');
-var util = require('util');
var yaml = require('./lib/js-yaml.js');
-require.extensions['.yml'] = require.extensions['.yaml'] =
- util.deprecate(function (m, f) {
- m.exports = yaml.safeLoad(fs.readFileSync(f, 'utf8'), { filename: f });
- }, 'Direct yaml files load via require() is deprecated! Use safeLoad() instead.');
-
-
module.exports = yaml;
View
@@ -1,7 +0,0 @@
-'use strict';
-
-
-var yaml = require('./lib/js-yaml.js');
-
-
-module.exports = yaml;
View
@@ -29,7 +29,6 @@
"mocha": "*"
},
"browser" : {
- "./index.js": "./index_browser.js",
"buffer": false
}
}
@@ -3,7 +3,7 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
it('Literal scalars have an unwanted leading line break', function () {
@@ -3,7 +3,7 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
it('Plain scalar "constructor" parsed as `null`', function () {
@@ -3,10 +3,12 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('Non-specific "!" tags should resolve to !!str', function () {
- var data = require('./data/issue-17.yml');
+ var data = yaml.safeLoad(readFileSync(__dirname + '/data/issue-17.yml', 'utf8'));
assert.equal(typeof data, 'string');
});
@@ -3,10 +3,12 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('Timestamp parsing is one month off', function () {
- var data = require('./data/issue-19.yml');
+ var data = yaml.safeLoad(readFileSync(__dirname + '/data/issue-19.yml', 'utf8'));
// JS month starts with 0 (0 => Jan, 1 => Feb, ...)
assert.equal(data.xmas.getTime(), Date.UTC(2011, 11, 24));
@@ -3,10 +3,12 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('should convert new line into white space', function () {
- var data = require('./data/issue-26.yml');
+ var data = yaml.safeLoad(readFileSync(__dirname + '/data/issue-26.yml', 'utf8'));
assert.equal(data.test, 'a b c\n');
});
@@ -3,10 +3,12 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('refactor compact variant of MarkedYAMLError.toString', function () {
assert.throws(
- function () { require('./data/issue-33.yml'); },
+ function () { yaml.safeLoad(readFileSync(__dirname + '/data/issue-33.yml', 'utf8')); },
"require('issue-33.yml') should throw, but it does not");
});
@@ -3,10 +3,13 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('Timestamps are incorrectly parsed in local time', function () {
- var data = require('./data/issue-46.yml'), date1, date2;
+ var data = yaml.safeLoad(readFileSync(__dirname + '/data/issue-46.yml', 'utf8'))
+ , date1, date2;
date1 = data.date1; // date1: 2010-10-20T20:45:00Z
assert.equal(date1.getUTCFullYear(), 2010, 'year');
@@ -3,10 +3,12 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it("Incorrect utf-8 handling on require('file.yaml')", function () {
- var data = require('./data/issue-54.yml'),
+ var data = yaml.safeLoad(readFileSync(__dirname + '/data/issue-54.yml', 'utf8')),
expected = '',
index;
@@ -3,11 +3,12 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('Wrong error message when yaml file contains tabs', function () {
assert.doesNotThrow(
- function () { require('./data/issue-64.yml'); },
+ function () { yaml.safeLoad(readFileSync(__dirname + '/data/issue-64.yml', 'utf8')); },
yaml.YAMLException);
});
@@ -3,7 +3,7 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
it('Prevent adding unnecessary space character to end of a line within block collections', function () {
@@ -3,10 +3,12 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('Parse failed when no document start present', function () {
assert.doesNotThrow(function () {
- require('./data/issue-8.yml');
+ yaml.safeLoad(readFileSync(__dirname + '/data/issue-8.yml', 'utf8'));
}, TypeError);
});
@@ -3,7 +3,7 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
var DEPRECATED_BOOLEANS_SYNTAX = [
@@ -3,7 +3,7 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
it('Invalid parse error on whitespace between quoted scalar keys and ":" symbol in mappings', function () {
@@ -3,10 +3,12 @@
var assert = require('assert');
+var yaml = require('../../');
+var readFileSync = require('fs').readFileSync;
it('Unwanted line breaks in folded scalars', function () {
- var data = require('./data/issue-93.yml');
+ var data = yaml.safeLoad(readFileSync(__dirname + '/data/issue-93.yml', 'utf8'));
assert.strictEqual(data.first, 'a b\n c\n d\ne f\n');
assert.strictEqual(data.second, 'a b\n c\n\n d\ne f\n');
@@ -3,7 +3,7 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
it('Empty block scalars loaded wrong', function () {
@@ -3,7 +3,7 @@
var assert = require('assert');
-var yaml = require('../../lib/js-yaml');
+var yaml = require('../../');
var sample = {

0 comments on commit 549ae1f

Please sign in to comment.