Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSON parsing support #224

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ var _jsYaml = require('js-yaml');

var _jsYaml2 = _interopRequireDefault(_jsYaml);

var _csonParser = require('cson-parser');

var _csonParser2 = _interopRequireDefault(_csonParser);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
Expand Down Expand Up @@ -76,6 +80,8 @@ function readFile(filename, callback) {
case '.yaml':
result = _jsYaml2.default.safeLoad(data);
break;
case '.cson':
result = _csonParser2.default.parse(data);
default:
result = JSON.parse(data);
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"homepage": "https://github.com/i18next/i18next-node-fs-backend",
"bugs": "https://github.com/i18next/i18next-node-fs-backend/issues",
"dependencies": {
"cson-parser": "3.0.0",
"js-yaml": "3.5.4",
"json5": "0.5.0"
},
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs';
import path from 'path';
import JSON5 from 'json5';
import YAML from 'js-yaml';
import CSON from 'cson-parser';

function getDefaults() {
return {
Expand Down Expand Up @@ -44,6 +45,8 @@ function readFile(filename, callback) {
case '.yaml':
result = YAML.safeLoad(data);
break;
case '.cson':
result = CSON.parse(data);
default:
result = JSON.parse(data);
}
Expand Down