Skip to content
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.

Commit

Permalink
feat: make it compatible with mos@1
Browse files Browse the repository at this point in the history
BREAKING CHANGES: can not work with mos@0
  • Loading branch information
zkochan committed May 13, 2016
1 parent 4217fe9 commit b9716df
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
17 changes: 3 additions & 14 deletions index.js
@@ -1,17 +1,6 @@
'use strict'
module.exports = plugin
module.exports = (mos, md) => Object.assign(mos.scope, require('./lib')(md))

const createShieldsRenderer = require('./lib/create-shields-renderer')

function plugin (markdown) {
if (!markdown.repo || markdown.repo.host !== 'github.com') {
throw new Error('The shields plugin only works for github repos')
}

return {
shields: createShieldsRenderer({
github: markdown.repo,
pkg: markdown.pkg,
}),
}
module.exports.attributes = {
pkg: require('./package.json'),
}
14 changes: 1 addition & 13 deletions index.spec.js
@@ -1,13 +1 @@
'use strict'
const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect

const mosPluginShields = require('.')

describe('mosPluginShields', () => {
it('should throw error when package hosted not on GitHub', () => {
expect(() => mosPluginShields({ repo: { host: 'gitlab' } }))
.to.throw(Error, 'The shields plugin only works for github repos')
})
})
require('.')
17 changes: 17 additions & 0 deletions lib/index.js
@@ -0,0 +1,17 @@
'use strict'
module.exports = plugin

const createShieldsRenderer = require('./create-shields-renderer')

function plugin (markdown) {
if (!markdown.repo || markdown.repo.host !== 'github.com') {
throw new Error('The shields plugin only works for github repos')
}

return {
shields: createShieldsRenderer({
github: markdown.repo,
pkg: markdown.pkg,
}),
}
}
13 changes: 13 additions & 0 deletions lib/index.spec.js
@@ -0,0 +1,13 @@
'use strict'
const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect

const mosPluginShields = require('.')

describe('mosPluginShields', () => {
it('should throw error when package hosted not on GitHub', () => {
expect(() => mosPluginShields({ repo: { host: 'gitlab' } }))
.to.throw(Error, 'The shields plugin only works for github repos')
})
})

0 comments on commit b9716df

Please sign in to comment.