Skip to content

Commit

Permalink
Add useNib option
Browse files Browse the repository at this point in the history
  • Loading branch information
tavriaforever committed Jul 15, 2015
1 parent c987192 commit b78b8c2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"dependencies": {
"autoprefixer-core": "5.2.0",
"nib": "1.1.0",
"postcss": "4.1.11",
"postcss-import": "5.2.2",
"postcss-url": "3.2.0",
Expand Down
8 changes: 8 additions & 0 deletions techs/stylus.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var path = require('path'),
url = require('postcss-url'),
stylus = require('stylus'),
autoprefixer = require('autoprefixer-core'),
nib = require('nib'),
EOL = require('os').EOL;

module.exports = require('enb/lib/build-flow').create()
Expand All @@ -69,6 +70,7 @@ module.exports = require('enb/lib/build-flow').create()
.defineOption('prefix', '')
.defineOption('includes', [])
.defineOption('hoist', false)
.defineOption('useNib', false)
.useFileList(['styl', 'css'])
.builder(function (sourceFiles) {
var node = this.node,
Expand Down Expand Up @@ -157,6 +159,12 @@ module.exports = require('enb/lib/build-flow').create()
});
}

if (this._useNib) {
renderer
.use(nib())
.import(this.node.relativePath('node_modules/nib'));
}

var defer = vow.defer();

this._configureRenderer(renderer).render(function (err, css) {
Expand Down
3 changes: 2 additions & 1 deletion test/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "enb-stylus-fixtures",
"private": true,
"dependencies": {
"stylus": "stylus/stylus#0.51.1"
"stylus": "stylus/stylus#0.51.1",
"nib": "1.1.0"
}
}
21 changes: 19 additions & 2 deletions test/stylus-tech.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var fs = require('fs'),
MockNode = require('mock-enb/lib/mock-node'),
FileList = require('enb/lib/file-list'),
StylusTech = require('../techs/stylus'),
stylus = mockFsHelper.duplicateFSInMemory(path.join(__dirname, 'fixtures', 'stylus'));
stylus = mockFsHelper.duplicateFSInMemory(path.join(__dirname, 'fixtures', 'stylus')),
nib = mockFsHelper.duplicateFSInMemory(path.join(__dirname, 'fixtures', 'nib'));

describe('stylus-tech', function () {
afterEach(function () {
Expand Down Expand Up @@ -223,6 +224,21 @@ describe('stylus-tech', function () {
});
});
});

describe('nib', function () {
it('must use mixins', function () {
var scheme = {
blocks: {
'block.styl': 'body\n\tsize 5em 10em'
}
},
expected = 'body{width:5em;height:10em;}';

return build(scheme, { useNib: true }).then(function (actual) {
actual.must.equal(expected);
});
});
});
});

function build (scheme, options) {
Expand All @@ -231,7 +247,8 @@ function build (scheme, options) {
bundle: {},
// jscs:disable
node_modules: {
stylus: stylus
stylus: stylus,
nib: nib
}
// jscs:enable
},
Expand Down

0 comments on commit b78b8c2

Please sign in to comment.