Skip to content

Commit

Permalink
Add support for scoped theme packages
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalduez committed Oct 7, 2017
1 parent 00bfe0c commit 5f38732
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,17 @@ export default class Environment extends EventEmitter {
return this.defaultTheme()
}

if (this.theme.indexOf('/') === -1) {
const isScoped =
this.theme.startsWith('@') &&
this.theme.includes('/')

const isPackage = !this.theme.includes('/')

if (isScoped) {
return this.tryTheme(this.theme)
}

if (isPackage) {
return this.tryTheme(`sassdoc-theme-${this.theme}`)
}

Expand Down
25 changes: 25 additions & 0 deletions test/env/environment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,31 @@ describe('#environment', function () {
})
})

/**
* A scoped package is passed as theme.
*/
describe('#theme-scoped', function () {
beforeEach(function () {
env.load({ theme: '@test/sassdoc-theme-test' })
env.postProcess()
env.data = []
mkdirp.sync('.sassdoc')
return env.theme('.sassdoc', env)
})

it('should warn and render the default theme', function () {
assert.notEqual(-1, warnings[0].indexOf('Theme `@test/sassdoc-theme-test` not found'))
assert.notEqual(-1, warnings[1].indexOf('Falling back to default theme'))
assert.ok(env.themeName === 'default')
assert.ok(fs.existsSync('.sassdoc/index.html'))
assert.ok(fs.existsSync('.sassdoc/assets'))
})

after(function (done) {
rimraf('.sassdoc', done)
})
})

/**
* ensureEnvironment
*/
Expand Down

0 comments on commit 5f38732

Please sign in to comment.