Skip to content

Commit 5525855

Browse files
committed
cs fix
1 parent 907792c commit 5525855

File tree

9 files changed

+1077
-55
lines changed

9 files changed

+1077
-55
lines changed

.editorconfig

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ root = true
22

33
[*]
44
indent_style = space
5-
indent_size = 4
5+
indent_size = 2
6+
tab_width = 2
7+
end_of_line = lf
68
charset = utf-8
79
trim_trailing_whitespace = true
8-
insert_final_newline = true
9-
10-
[*.md]
11-
trim_trailing_whitespace = false
12-
13-
[*.json]
14-
indent_style = space
15-
indent_size = 2
10+
insert_final_newline = true

.eslintrc.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"extends": "eslint:recommended",
6+
"rules": {
7+
"indent": [
8+
"error",
9+
2
10+
],
11+
"linebreak-style": [
12+
"error",
13+
"unix"
14+
],
15+
"quotes": [
16+
"error",
17+
"single"
18+
],
19+
"semi": [
20+
"error",
21+
"always"
22+
]
23+
}
24+
}

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.editorconfig
22
.gitignore
33
.npmignore
4+
.eslintrc.json
45
.idea/
56
.git/

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
3+
node_js:
4+
- "4"
5+
- "stable"
6+
7+
install:
8+
- npm install
9+
10+
script:
11+
- npm test
12+
13+
notifications:
14+
email: false

CHANGELOG.md

Whitespace-only changes.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Igor Ognichenko
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

index.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,73 +11,73 @@ var md5 = require('md5');
1111
var fileExists = require('file-exists');
1212

1313
module.exports = function (opt) {
14-
var options = merge({
15-
output_assets: null,
16-
output_css: null,
17-
exclude: [],
18-
overwrite: false
19-
}, opt);
14+
var options = merge({
15+
output_assets: null,
16+
output_css: null,
17+
exclude: [],
18+
overwrite: false
19+
}, opt);
2020

21-
return through.obj(function (file, enc, cb) {
22-
if (file.isNull()) {
23-
return;
24-
}
21+
return through.obj(function (file, enc, cb) {
22+
if (file.isNull()) {
23+
return;
24+
}
2525

26-
if (file.isStream()) {
27-
return this.emit('error', PluginError('gulp-css-rebase', 'Streaming not supported'));
28-
}
26+
if (file.isStream()) {
27+
return this.emit('error', PluginError('gulp-css-rebase', 'Streaming not supported')); // eslint-disable-line
28+
}
2929

30-
var adjusted = adjust(file);
31-
file.contents = new Buffer(adjusted);
30+
var adjusted = adjust(file);
31+
file.contents = new Buffer(adjusted);
3232

33-
cb(null, file);
34-
});
33+
cb(null, file);
34+
});
3535

36-
function adjust(file) {
37-
var css = file.contents.toString();
36+
function adjust(file) {
37+
var css = file.contents.toString();
3838

39-
return rework(css)
39+
return rework(css)
4040
.use(url(function (url) {
41-
if (!/^(data|\/|\w+:\/\/)/.test(url)) {
42-
var assetPath = path.join(path.dirname(file.path), url);
43-
var assetFolder = md5(path.relative(process.cwd(), path.dirname(assetPath)));
44-
var IsExclude = false;
41+
if (!/^(data|\/|\w+:\/\/)/.test(url)) {
42+
var assetPath = path.join(path.dirname(file.path), url);
43+
var assetFolder = md5(path.relative(process.cwd(), path.dirname(assetPath)));
44+
var IsExclude = false;
4545

46-
for (var index in options.exclude) {
47-
if (options.exclude[index] === assetPath.substr(0, options.exclude[index].length)) {
48-
IsExclude = true;
49-
break;
50-
}
51-
}
46+
for (var index in options.exclude) {
47+
if (options.exclude[index] === assetPath.substr(0, options.exclude[index].length)) {
48+
IsExclude = true;
49+
break;
50+
}
51+
}
5252

53-
var newPath = !IsExclude
53+
var newPath = !IsExclude
5454
? path.normalize(path.join(options.output_assets, assetFolder, path.basename(assetPath)))
5555
: path.normalize(assetPath)
5656
;
5757

58-
if (
58+
if (
5959
(!IsExclude && !fileExists(newPath))
6060
||
6161
(!IsExclude && options.overwrite)
6262
) {
63-
mkpath(path.dirname(newPath), function (err) {
64-
if (err) {
65-
throw err;
66-
}
63+
mkpath(path.dirname(newPath), function (err) {
64+
if (err) {
65+
throw err;
66+
}
6767

68-
fs
68+
fs
6969
.createReadStream(assetPath.replace(/[\#|\?].*$/, ''))
7070
.pipe(fs.createWriteStream(newPath.replace(/[\#|\?].*$/, '')))
7171
;
72-
});
72+
});
7373

74-
}
75-
76-
url = path.relative(options.output_css, newPath);
7774
}
7875

79-
return url;
76+
url = path.relative(options.output_css, newPath);
77+
}
78+
79+
return url;
8080
}))
8181
.toString();
82-
}
82+
}
8383
};

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@
1414
"rework-plugin-url": "^1.1.0",
1515
"through2": "^0.6.5"
1616
},
17-
"devDependencies": {},
17+
"devDependencies": {
18+
"eslint": "^3.19.0"
19+
},
1820
"scripts": {
19-
"test": "echo \"Error: no test specified\" && exit 1"
21+
"test": "node_modules/.bin/eslint .",
22+
"patch": "npm version patch && git push origin master --follow-tags && npm publish",
23+
"minor": "npm version minor && git push origin master --follow-tags && npm publish",
24+
"major": "npm version major && git push origin master --follow-tags && npm publish"
2025
},
2126
"repository": {
2227
"type": "git",
2328
"url": "git+https://github.com/RobinCK/gulp-css-rebase.git"
2429
},
2530
"author": "Igor Ognichenko <ognichenko.igor@gmail.com>",
26-
"license": "ISC",
31+
"license": "MIT",
2732
"bugs": {
2833
"url": "https://github.com/RobinCK/gulp-css-rebase/issues"
2934
},

0 commit comments

Comments
 (0)