-
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
0 parents
commit 5ec2fc0
Showing
8 changed files
with
227 additions
and
0 deletions.
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,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,5 @@ | ||
.DS_Store | ||
node_modules | ||
|
||
coverage | ||
npm-debug.log |
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,17 @@ | ||
sudo: required | ||
dist: trusty | ||
language: node_js | ||
node_js: | ||
- "4" | ||
- "5" | ||
- "6" | ||
before_install: | ||
- sudo apt-get -y install python3-pip python-dev | ||
- sudo pip3 install -U setuptools | ||
- python3 -V | ||
- pip3 -V | ||
install: | ||
- npm install | ||
- sudo pip3 install isort | ||
after_script: | ||
- 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2016 Sophilabs | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,50 @@ | ||
# Gulp Isort | ||
|
||
[![travis][travis-image]][travis-url] | ||
[![coverage][coveralls-image]][coveralls-url] | ||
[![npm][npm-image]][npm-url] | ||
[![downloads][downloads-image]][downloads-url] | ||
[![js-semistandard-style][semi-image]][semi-url] | ||
[![license][license-image]][license-url] | ||
[![dependencies][dependencies-image]][dependencies-url] | ||
[![dev-dependencies][dev-dependencies-image]][dev-dependencies-url] | ||
|
||
Gulp task for isort. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install gulp-isort | ||
``` | ||
|
||
## License | ||
|
||
Gulp Isort is Copyright (c) 2016 sophilabs, inc. It is free software, and may be | ||
redistributed under the terms specified in the [license] file. | ||
|
||
## About | ||
|
||
[![sophilabs][sophilabs-image]][sophilabs-url] | ||
|
||
Gulp Isort is maintained and funded by sophilabs, inc. The names and logos for | ||
sophilabs are trademarks of sophilabs, inc. | ||
|
||
[license]: /LICENSE | ||
[sophilabs-image]: https://res.cloudinary.com/jsconfuy/image/upload/c_pad,f_auto,h_200,w_200,e_trim/v1426608244/xuwbunompvfjaxuazlwo.png | ||
[sophilabs-url]: https://sophilabs.co | ||
[travis-image]: https://img.shields.io/travis/sophilabs/gulp-isort.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/sophilabs/gulp-isort | ||
[npm-image]: https://img.shields.io/npm/v/gulp-isort.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/packge/gulp-isort | ||
[downloads-image]: https://img.shields.io/npm/dm/gulp-isort.svg?style=flat-square | ||
[downloads-url]: https://npmjs.org/package/gulp-isort | ||
[semi-image]: https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square | ||
[semi-url]: https://github.com/Flet/semistandard | ||
[coveralls-image]: https://img.shields.io/coveralls/sophilabs/gulp-isort.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/github/sophilabs/gulp-isort?branch=master | ||
[license-image]: https://img.shields.io/github/license/sophilabs/gulp-isort.svg?style=flat-square | ||
[license-url]: /LICENSE | ||
[dependencies-image]: https://david-dm.org/sophilabs/gulp-isort.svg?style=flat-square | ||
[dependencies-url]: https://david-dm.org/sophilabs/gulp-isort | ||
[dev-dependencies-image]: https://david-dm.org/sophilabs/gulp-isort/dev-status.svg?style=flat-square | ||
[dev-dependencies-url]: https://david-dm.org/sophilabs/gulp-isort#info=devDependencies |
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,48 @@ | ||
'use strict'; | ||
var util = require('util'); | ||
var path = require('path'); | ||
var gutil = require('gulp-util'); | ||
var through = require('through2'); | ||
var cp = require('child_process'); | ||
|
||
function gulpIsort(opts) { | ||
opts = opts || {}; | ||
|
||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} else if (file.isStream()) { | ||
cb(new gutil.PluginError('gulp-isort', 'Streaming not supported')); | ||
return; | ||
} | ||
file.isort = {}; | ||
var isort = cp.spawn('isort', ['-c', '-']); | ||
isort.stdout.on('data', function (data) { | ||
file.isort.errors = util.format('%s\n%s', file.path, data.toString().trim()); | ||
}); | ||
isort.on('exit', function (code) { | ||
cb(null, file); | ||
}); | ||
isort.stdin.write(file.contents); | ||
isort.stdin.end(); | ||
}); | ||
}; | ||
|
||
gulpIsort.failOnError = function() { | ||
return through.obj(function (file, enc, cb) { | ||
if (!file.isort || !file.isort.errors) { | ||
cb(null, file); | ||
return; | ||
} | ||
cb(new gutil.PluginError( | ||
'gulp-isort', | ||
{ | ||
name: 'IsortError', | ||
message: file.isort.errors | ||
} | ||
)); | ||
}); | ||
}; | ||
|
||
module.exports = gulpIsort; |
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,40 @@ | ||
{ | ||
"name": "gulp-isort", | ||
"version": "0.0.1", | ||
"description": "Gulp plugin for Isort.", | ||
"main": "lib/index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec $(find ./test -name *.tests.js) && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"lint": "semistandard *.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sophilabs/gulp-isort.git" | ||
}, | ||
"keywords": [ | ||
"isort", | ||
"python", | ||
"gulpplugin" | ||
], | ||
"author": "Sophilabs", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sophilabs/gulp-isort/issues" | ||
}, | ||
"homepage": "https://github.com/sophilabs/gulp-isort#readme", | ||
"dependencies": { | ||
"gulp-util": "^3.0.7", | ||
"through2": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.9", | ||
"istanbul": "^0.4.4", | ||
"mocha": "^2.5.3", | ||
"semistandard": "^8.0.0", | ||
"should": "^9.0.2", | ||
"vinyl": "^1.1.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,34 @@ | ||
'use strict'; | ||
|
||
var gulpIsort = require('../lib'); | ||
var should = require('should'); | ||
var File = require('vinyl'); | ||
|
||
require('mocha'); | ||
|
||
describe('gulp-isort failOnError', function() { | ||
it('should fail a file immediately if an error is found', function(done) { | ||
var lintStream = gulpIsort(); | ||
|
||
function endWithoutError() { | ||
done(new Error('An error was not thrown before ending')); | ||
} | ||
|
||
lintStream.pipe(gulpIsort.failOnError()) | ||
.on('error', function(err) { | ||
this.removeListener('finish', endWithoutError); | ||
should.exists(err); | ||
err.message.should.equal('test/fixtures/invalid.py\nERROR: Imports are incorrectly sorted.'); | ||
err.plugin.should.equal('gulp-isort'); | ||
done(); | ||
}) | ||
.on('finish', endWithoutError); | ||
|
||
lintStream.write(new File({ | ||
path: 'test/fixtures/invalid.py', | ||
contents: new Buffer('import b\nimport a') | ||
})); | ||
|
||
lintStream.end(); | ||
}); | ||
}); |