Skip to content

Commit

Permalink
Drop node 0.x support, update through2 and lab
Browse files Browse the repository at this point in the history
only node LTS (4) + latest supported/tested now

Switch to arrow functions
  • Loading branch information
pushred committed Aug 3, 2016
1 parent 4a4ec76 commit b91df03
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
6 changes: 5 additions & 1 deletion circle.yml
@@ -1,3 +1,7 @@
machine:
node:
version: v0.10
version: v4.4.7
dependencies:
# https://discuss.circleci.com/t/testing-multiple-versions-of-node/542
pre:
- case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=4 ;; 1) NODE_VERSION=6 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -61,7 +61,7 @@ module.exports = function (config, marked_options) {
if (util.isArray(input)){
var data = {};

input.forEach(function (file) {
input.forEach(file => {
const file_data = JSON.parse(parse(file).contents.toString());

data = extend(file_data, data);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -16,7 +16,7 @@
"url": "https://github.com/sparkartgroupinc/gulp-markdown-to-json.git"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4.4.7"
},
"scripts": {
"lint": "semistandard **/*.js",
Expand All @@ -42,12 +42,12 @@
"gulp-util": "^2.2.0",
"marked": "^0.3.0",
"sort-object": "^0.0.6",
"through2": "^0.4.0",
"through2": "^2.0.1",
"util-extend": "^1.0.1"
},
"devDependencies": {
"expect": "^1.20.2",
"lab": "^5.16.0",
"lab": "^10.9.0",
"semistandard": "^8.0.0",
"vinyl-fs": "~0.3.5"
}
Expand Down
44 changes: 22 additions & 22 deletions test/test.js
Expand Up @@ -22,72 +22,72 @@ const fixtureConfig = [{
contents: new Buffer('---\ntitle: lipsum ipsum\n---\n# Titulus\n*"tipsum"*')
}];

lab.experiment('Markdown and YAML parsing', function () {
lab.test('should parse Markdown content and return markup wrapped in JSON', function (done) {
lab.experiment('Markdown and YAML parsing', () => {
lab.test('should parse Markdown content and return markup wrapped in JSON', done => {
const fixture = new gutil.File(fixtureConfig[0]);

markdown()
.on('data', function (file) {
.on('data', file => {
expect(JSON.parse(file.contents.toString()));
done();
})
.write(fixture);
});

lab.test('should pass on configuration objects to the marked module', function (done) {
lab.test('should pass on configuration objects to the marked module', done => {
const fixture = new gutil.File(fixtureConfig[0]);

markdown({
smartypants: true
})
.on('data', function (file) {
.on('data', file => {
expect(file.contents.toString().match(//));
done();
})
.write(fixture);
});

lab.test('should parse YAML front matter and merge keys', function (done) {
lab.test('should parse YAML front matter and merge keys', done => {
const fixture = new gutil.File(fixtureConfig[0]);

markdown()
.on('data', function (file) {
.on('data', file => {
const json = JSON.parse(file.contents.toString());
expect(json.title);
done();
})
.write(fixture);
});

lab.test('should extract a title if first line of Markdown is an atx-style h1', function (done) {
lab.test('should extract a title if first line of Markdown is an atx-style h1', done => {
const fixture = new gutil.File(fixtureConfig[1]);

markdown()
.on('data', function (file) {
.on('data', file => {
const json = JSON.parse(file.contents.toString());
expect(json.title && json.title === 'Titulus');
done();
})
.write(fixture);
});

lab.test('should extract a title if first line of Markdown is a setext-style h1', function (done) {
lab.test('should extract a title if first line of Markdown is a setext-style h1', done => {
const fixture = new gutil.File(fixtureConfig[2]);

markdown()
.on('data', function (file) {
.on('data', file => {
const json = JSON.parse(file.contents.toString());
expect(json.title && json.title === 'Titulus');
done();
})
.write(fixture);
});

lab.test('should prefer YAML front matter titles over a extracted Markdown h1', function (done) {
lab.test('should prefer YAML front matter titles over a extracted Markdown h1', done => {
const fixture = new gutil.File(fixtureConfig[3]);

markdown()
.on('data', function (file) {
.on('data', file => {
const json = JSON.parse(file.contents.toString());
expect(json.title && json.title === 'lipsum ipsum');
done();
Expand All @@ -96,47 +96,47 @@ lab.experiment('Markdown and YAML parsing', function () {
});
});

lab.experiment('Output', function () {
lab.test('should return JSON for all Markdown in a specified directory structure', function (done) {
lab.experiment('Output', () => {
lab.test('should return JSON for all Markdown in a specified directory structure', done => {
fs.src(fixturePath)
.pipe(markdown())
.on('data', function (file) {
.on('data', file => {
expect(JSON.parse(file.contents.toString()));
})
.on('finish', done);
});

lab.test('should consolidate output into a single file if buffered with gulp-util', function (done) {
lab.test('should consolidate output into a single file if buffered with gulp-util', done => {
const stream = fs.src(fixturePath)
.pipe(gutil.buffer())
.pipe(markdown());

stream.on('finish', function () {
stream.on('finish', () => {
expect(stream._readableState.length).toEqual(1);
expect(stream._readableState.buffer[0].path).toEqual('/content.json');
done();
});
});

lab.test('should allow the single file to be renamed', function (done) {
lab.test('should allow the single file to be renamed', done => {
const stream = fs.src(fixturePath)
.pipe(gutil.buffer())
.pipe(markdown('blog.json', {
smartypants: true
}));

stream.on('finish', function () {
stream.on('finish', () => {
expect(stream._readableState.buffer[0].path).toEqual('/blog.json');
expect(stream._readableState.buffer[0].contents.toString()).toInclude('“');
done();
});
});

lab.test('should represent the directory structure as a nested object', function (done) {
lab.test('should represent the directory structure as a nested object', done => {
fs.src(fixturePath)
.pipe(gutil.buffer())
.pipe(markdown())
.on('data', function (file) {
.on('data', file => {
const json = JSON.parse(file.contents.toString());
expect(json.blog.posts['oakland-activist']);
})
Expand Down

0 comments on commit b91df03

Please sign in to comment.