Skip to content

Commit

Permalink
Merge pull request #65 from bem/yeti-or.tests
Browse files Browse the repository at this point in the history
Add tests
  • Loading branch information
Yeti-or committed Mar 12, 2018
2 parents 436e367 + a228cd6 commit 590ea06
Show file tree
Hide file tree
Showing 14 changed files with 7,936 additions and 955 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parserOptions" : {
"ecmaVersion" : 6,
"ecmaVersion" : 8,
"sourceType" : "module"
},
"rules" : {
Expand Down Expand Up @@ -33,7 +33,7 @@
"array-bracket-spacing" : ["error", "never"],
"func-call-spacing" : "error",
"space-before-blocks" : ["error", "always"],
"quotes" : ["error", "single", { "avoidEscape" : true }],
"quotes" : ["error", "single", { "avoidEscape" : true, "allowTemplateLiterals": true }],
"camelcase" : ["error", { "properties" : "never" }],
"no-trailing-spaces" : "error",
"comma-dangle" : ["error", "never"]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
coverage
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sudo: false

language: node_js

matrix:
include:
- node_js: "8"
- node_js: "9"
env: COVERALLS=1

after_success:
- if [ "x$COVERALLS" = "x1" ] && npm i coveralls; then
npm run cover -- --coverageReporters=text-lcov | coveralls;
fi

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ module: {

## Options

- __naming__: [bem-naming](https://en.bem.info/toolbox/sdk/bem-naming-entity/#naming-conventions) overrides
- __levels__ <Array>: paths to components declarations
- __levels__ <Array>: *Required option* — paths to components declarations
- __naming__: [bem-naming](https://en.bem.info/toolbox/sdk/bem-naming-entity/#naming-conventions) overrides naming
- __techs__ <Array>: list of techs extensions for require in runtime, `['js']` by default. First tech will be default export
- __techMap__ <Object>: mapping of techs to extensions. Example: `{ 'js' : ['react.js', 'react.ts', 'react.es'], 'css' : ['post.css'] }`
- __langs__ <Array>: list of langs in which resloves '.i18n' tech
Expand Down
24 changes: 10 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const path = require('path'),
bemConfig = require('bem-config')(),
requiredPath = require('required-path'),
falafel = require('falafel'),
vow = require('vow'),
vowFs = require('vow-fs'),
loaderUtils = require('loader-utils'),
getGenerators = require('./generators');

Expand Down Expand Up @@ -76,21 +74,19 @@ module.exports = function(source) {

this.addDependency(entityPath);

return vowFs
.exists(entityPath)
.then(exist => {
// BemFile
return {
cell : bemCell,
exist,
// prepare path for require cause relative returns us string that we couldn't require
path : unifyPath(requiredPath(path.relative(path.dirname(this.resourcePath), entityPath)))
};
return new Promise(resolve => this.fs.stat(entityPath, err => {
// BemFile
resolve({
cell : bemCell,
exist : !err,
// prepare path for require cause relative returns us string that we couldn't require
path : unifyPath(requiredPath(path.relative(path.dirname(this.resourcePath), entityPath)))
});
}));
});

existingEntitiesPromises.length && allPromises.push(
vow
Promise
.all(existingEntitiesPromises)
.then(bemFiles => {
/**
Expand Down Expand Up @@ -151,7 +147,7 @@ module.exports = function(source) {
);
});

vow.all(allPromises)
Promise.all(allPromises)
.then(() => callback(null, result.toString()))
.catch(callback);
};

0 comments on commit 590ea06

Please sign in to comment.