Skip to content

Commit 8d066f9

Browse files
committed
Return a promise from postcss-import transform function
1 parent 0159802 commit 8d066f9

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,5 @@ function lintImportedFiles(options, css, filename) {
132132
.use(bemLinter(options['postcss-bem-linter']))
133133
.use(reporter(options['postcss-reporter']));
134134

135-
return processor.process(css, {from: filename}).css;
135+
return processor.process(css, {from: filename});
136136
}

test/error.config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"postcss-reporter": {
3-
"throwError": true,
4-
"plugins": ["postcss-bem-linter"]
3+
"throwError": true
54
}
65
}

test/test.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ describe('suitcss', function() {
172172
var lintImportedFilesStub, beforeLintStub, revert;
173173

174174
beforeEach(function() {
175-
lintImportedFilesStub = sinon.stub().returns('/*linting done*/');
175+
var postcssPromise = sinon.stub().resolves('/*linting done*/')();
176+
lintImportedFilesStub = sinon.stub().returns(postcssPromise);
176177
beforeLintStub = sinon.stub().returns('/*before lint*/');
177178
revert = suitcss.__set__('lintImportedFiles', lintImportedFilesStub);
178179
});
@@ -185,35 +186,38 @@ describe('suitcss', function() {
185186
suitcss(read('fixtures/component'), {
186187
root: 'test/fixtures',
187188
beforeLint: beforeLintStub
188-
}).catch(done);
189-
190-
expect(lintImportedFilesStub).to.be.calledOnce;
191-
expect(beforeLintStub).to.be.calledOnce;
192-
expect(beforeLintStub).to.have.been.calledBefore(lintImportedFilesStub);
193-
194-
done();
189+
})
190+
.then(function() {
191+
expect(beforeLintStub).to.be.calledOnce;
192+
expect(lintImportedFilesStub).to.be.calledOnce;
193+
expect(beforeLintStub).to.have.been.calledBefore(lintImportedFilesStub);
194+
done();
195+
})
196+
.catch(done);
195197
});
196198

197199
it('should pass the result of `beforeLint` to `lintImportedFiles`', function(done) {
198200
suitcss(read('fixtures/component'), {
199201
root: 'test/fixtures',
200202
beforeLint: beforeLintStub
201-
}).catch(done);
202-
203-
expect(lintImportedFilesStub.args[0][1]).to.equal('/*before lint*/');
204-
205-
done();
203+
})
204+
.then(function() {
205+
expect(lintImportedFilesStub.args[0][1]).to.equal('/*before lint*/');
206+
done();
207+
})
208+
.catch(done);
206209
});
207210

208211
it('should pass the options object to the beforeLint function as the third parameter', function(done) {
209212
suitcss(read('fixtures/component'), {
210213
root: 'test/fixtures',
211214
beforeLint: beforeLintStub
212-
}).catch(done);
213-
214-
expect(beforeLintStub.args[0][2]).to.contain({root: 'test/fixtures'});
215-
216-
done();
215+
})
216+
.then(function() {
217+
expect(beforeLintStub.args[0][2]).to.contain({root: 'test/fixtures'});
218+
done();
219+
})
220+
.catch(done);
217221
});
218222
});
219223
});

0 commit comments

Comments
 (0)