Skip to content
This repository was archived by the owner on Dec 22, 2020. It is now read-only.

Commit 889c66d

Browse files
authored
Merge pull request #15 from stevelacy/master
Features: update module, add tests
2 parents e874212 + 1b691b6 commit 889c66d

File tree

5 files changed

+90
-13
lines changed

5 files changed

+90
-13
lines changed

.eslintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"rules": {
6+
"strict": 0,
7+
"camelcase": 0,
8+
"curly": 0,
9+
"indent": [2, 2, { "SwitchCase": 1 }],
10+
"eol-last": 1,
11+
"no-shadow": 0,
12+
"no-redeclare": 2,
13+
"no-extra-bind": 1,
14+
"no-empty": 0,
15+
"no-process-exit": 1,
16+
"no-underscore-dangle": 0,
17+
"no-use-before-define": 0,
18+
"no-unused-vars": 0,
19+
"consistent-return": 0,
20+
"no-inner-declarations": 1,
21+
"no-loop-func": 1
22+
}
23+
}

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- "4"
5+
- "6"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ Don't forget to polyfill require if you want to use it in Node.js. See the webpa
116116
<br />
117117
<a href="https://github.com/">Kent C. Dodds</a>
118118
</td>
119+
<td align="center">
120+
<img width="150" height="150"
121+
src="https://avatars.githubusercontent.com/stevelacy?v=3">
122+
<br />
123+
<a href="https://github.com/stevelacy">Steve Lacy</a>
124+
</td>
119125
<tr>
120126
<tbody>
121127
</table>

package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
2-
"name": "json5-loader",
3-
"version": "0.6.0",
4-
"author": "Tobias Koppers @sokra",
5-
"description": "json5 loader module for webpack",
6-
"peerDependencies": {
7-
"json5": ">= 0.2.0 <= 0.5"
8-
},
9-
"licenses": [
10-
{
11-
"type": "MIT",
12-
"url": "http://www.opensource.org/licenses/mit-license.php"
13-
}
14-
]
2+
"name": "json5-loader",
3+
"version": "1.0.0",
4+
"author": "Tobias Koppers @sokra",
5+
"description": "json5 loader module for webpack",
6+
"dependencies": {
7+
"json5": "^0.5.0"
8+
},
9+
"license": "MIT",
10+
"devDependencies": {
11+
"mocha": "^3.0.2",
12+
"should": "^11.1.0"
13+
},
14+
"scripts": {
15+
"test": "mocha test/*.js"
16+
}
1517
}

test/loader.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
var should = require('should');
4+
var PROJECT_NAME = require('../package.json').name;
5+
var loader = require('..');
6+
var staticJson5 = "{name: 'test'}";
7+
8+
describe(PROJECT_NAME, function () {
9+
it('should export the loader', function (done) {
10+
should(loader).be.type('function');
11+
done();
12+
});
13+
14+
it('should export a default for es2015 support', function (done) {
15+
should.exist(loader.default);
16+
should(loader.default).be.type('function');
17+
done();
18+
});
19+
20+
it('should convert to requires', function (done) {
21+
var content = loader.call({}, staticJson5);
22+
should(content).be.eql('module.exports = {\n\t"name": "test"\n}');
23+
done();
24+
});
25+
26+
it('should fire cacheable', function (done) {
27+
var cacheable = function () {
28+
done();
29+
};
30+
var content = loader.call({cacheable: cacheable}, staticJson5);
31+
should(content).be.eql('module.exports = {\n\t"name": "test"\n}');
32+
});
33+
34+
it('should catch invalid JSON5', function (done) {
35+
var brokenJson5 = '{broken: json5}';
36+
should(function () {
37+
loader.call({}, brokenJson5);
38+
}).throw('Error using JSON5 parsing');
39+
done();
40+
});
41+
});

0 commit comments

Comments
 (0)