-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de00a64
commit f679e73
Showing
7 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"extends": "eslint:recommended", | ||
"env": { | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
} | ||
}, | ||
"rules": { | ||
"semi": 2 | ||
}, | ||
"globals": { | ||
"Promise": 1, | ||
"panto": 1, | ||
"Map": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*DS_Store | ||
._* | ||
*.swp | ||
*.pyc | ||
node-debug.log | ||
npm-debug.log | ||
node_modules | ||
bower_components | ||
.svn | ||
test/**/out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: node_js | ||
before_install: | ||
- npm install -g eslint | ||
sudo: false | ||
node_js: | ||
- stable | ||
after_script: | ||
- npm install -g istanbul | ||
- npm run coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# load-panto-transformers | ||
Automatically load panto transformers | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
|
||
Automatically load panto transformers, inspired by [load-grunt-tasks](https://www.npmjs.com/package/load-grunt-tasks). | ||
|
||
```js | ||
require('load-panto-transformers')(panto); | ||
`` | ||
|
||
[npm-url]: https://npmjs.org/package/load-panto-transformers | ||
[downloads-image]: http://img.shields.io/npm/dm/load-panto-transformers.svg | ||
[npm-image]: http://img.shields.io/npm/v/load-panto-transformers.svg | ||
[travis-url]: https://travis-ci.org/pantojs/load-panto-transformers | ||
[travis-image]: http://img.shields.io/travis/pantojs/load-panto-transformers.svg | ||
[david-dm-url]:https://david-dm.org/pantojs/load-panto-transformers | ||
[david-dm-image]:https://david-dm.org/pantojs/load-panto-transformers.svg | ||
[david-dm-dev-url]:https://david-dm.org/pantojs/load-panto-transformers#info=devDependencies | ||
[david-dm-dev-image]:https://david-dm.org/pantojs/load-panto-transformers/dev-status.svg | ||
[coveralls-image]:https://coveralls.io/repos/github/pantojs/load-panto-transformers/badge.svg?branch=master | ||
[coveralls-url]:https://coveralls.io/github/pantojs/load-panto-transformers?branch=master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (C) 2016 pantojs.xyz | ||
* index.js | ||
* | ||
* changelog | ||
* 2016-07-31[22:42:28]:revised | ||
* | ||
* @author yanni4night@gmail.com | ||
* @version 0.1.0 | ||
* @since 0.1.0 | ||
*/ | ||
|
||
'use strict'; | ||
const path = require('path'); | ||
const pkgUp = require('pkg-up'); | ||
const multimatch = require('multimatch'); | ||
const camelCase = require('lodash/camelCase'); | ||
const arrify = require('arrify'); | ||
|
||
module.exports = (panto, opts) => { | ||
opts = opts || {}; | ||
|
||
const pattern = arrify(opts.pattern || ['panto-transformer-*']); | ||
let config = opts.config || pkgUp.sync(); | ||
const scope = arrify(opts.scope || ['dependencies', 'devDependencies', 'peerDependencies', | ||
'optionalDependencies' | ||
]); | ||
|
||
if (typeof config === 'string') { | ||
config = require(path.resolve(config)); | ||
} | ||
|
||
const names = scope.reduce((result, prop) => { | ||
const deps = config[prop] || []; | ||
return result.concat(Array.isArray(deps) ? deps : Object.keys(deps)); | ||
}, []); | ||
|
||
multimatch(names, pattern).forEach(pkgName => { | ||
panto.loadTransformer(camelCase(pkgName.replace('panto-transformer-', '')), require(pkgName)); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "load-panto-transformers", | ||
"version": "0.1.0", | ||
"description": "Automatically load panto transformers", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "eslint index.js && ./node_modules/.bin/mocha", | ||
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" | ||
}, | ||
"pre-commit": "test", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/pantojs/load-panto-transformers.git" | ||
}, | ||
"engines": { | ||
"node": ">=6.0.0" | ||
}, | ||
"keywords": [ | ||
"panto", | ||
"load", | ||
"transformer" | ||
], | ||
"author": "yanni4night@gmail.com", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/pantojs/load-panto-transformers/issues" | ||
}, | ||
"homepage": "https://github.com/pantojs/load-panto-transformers#readme", | ||
"dependencies": { | ||
"arrify": "^1.0.1", | ||
"lodash": "^4.14.1", | ||
"multimatch": "^2.1.0", | ||
"pkg-up": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.12", | ||
"mocha": "^2.5.3", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"panto": "0.0.30", | ||
"panto-transformer-css-sprites": "0.0.4", | ||
"panto-transformer-filter": "^0.1.4", | ||
"pre-commit": "^1.1.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (C) 2016 pantojs.xyz | ||
* test.js | ||
* | ||
* changelog | ||
* 2016-07-31[22:57:35]:revised | ||
* | ||
* @author yanni4night@gmail.com | ||
* @version 0.1.0 | ||
* @since 0.1.0 | ||
*/ | ||
'use strict'; | ||
const assert = require('assert'); | ||
const load = require('../'); | ||
const panto = require('panto'); | ||
|
||
describe('load-panto-transformer', () => { | ||
describe('#load', () => { | ||
it('should load filter', () => { | ||
load(panto); | ||
const s = panto.$('*.js'); | ||
assert.ok(s.filter, 'has filter'); | ||
assert.ok(s.cssSprites, 'has cssSprites'); | ||
}); | ||
}); | ||
}); |