gulp-css-rebase
Advanced tools
Comparing version 2.0.2 to 2.0.3
86
index.js
@@ -14,42 +14,42 @@ 'use strict'; | ||
module.exports = function (opt) { | ||
var options = merge({ | ||
output_assets: null, | ||
output_css: null, | ||
exclude: [], | ||
overwrite: false | ||
}, opt); | ||
var options = merge({ | ||
output_assets: null, | ||
output_css: null, | ||
exclude: [], | ||
overwrite: false | ||
}, opt); | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
return; | ||
} | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
return; | ||
} | ||
if (file.isStream()) { | ||
return this.emit('error', PluginError('gulp-css-rebase', 'Streaming not supported')); | ||
} | ||
if (file.isStream()) { | ||
return this.emit('error', PluginError('gulp-css-rebase', 'Streaming not supported')); // eslint-disable-line | ||
} | ||
var adjusted = adjust(file); | ||
file.contents = new Buffer(adjusted); | ||
var adjusted = adjust(file); | ||
file.contents = new Buffer(adjusted); | ||
cb(null, file); | ||
}); | ||
cb(null, file); | ||
}); | ||
function adjust(file) { | ||
var css = file.contents.toString(); | ||
function adjust(file) { | ||
var css = file.contents.toString(); | ||
return rework(css) | ||
return rework(css) | ||
.use(url(function (url) { | ||
if (!/^(data|\/|\w+:\/\/)/.test(url)) { | ||
var assetPath = path.join(path.dirname(file.path), url); | ||
var assetFolder = md5(path.relative(process.cwd(), path.dirname(assetPath))); | ||
var IsExclude = false; | ||
if (!/^(data|\/|\w+:\/\/)/.test(url)) { | ||
var assetPath = path.join(path.dirname(file.path), url); | ||
var assetFolder = md5(path.relative(process.cwd(), path.dirname(assetPath))); | ||
var IsExclude = false; | ||
for (var index in options.exclude) { | ||
if (options.exclude[index] === assetPath.substr(0, options.exclude[index].length)) { | ||
IsExclude = true; | ||
break; | ||
} | ||
} | ||
for (var index in options.exclude) { | ||
if (options.exclude[index] === assetPath.substr(0, options.exclude[index].length)) { | ||
IsExclude = true; | ||
break; | ||
} | ||
} | ||
var newPath = !IsExclude | ||
var newPath = !IsExclude | ||
? path.normalize(path.join(options.output_assets, assetFolder, path.basename(assetPath))) | ||
@@ -59,3 +59,3 @@ : path.normalize(assetPath) | ||
if ( | ||
if ( | ||
(!IsExclude && !fileExists(newPath)) | ||
@@ -65,22 +65,22 @@ || | ||
) { | ||
mkpath(path.dirname(newPath), function (err) { | ||
if (err) { | ||
throw err; | ||
} | ||
mkpath(path.dirname(newPath), function (err) { | ||
if (err) { | ||
throw err; | ||
} | ||
fs | ||
fs | ||
.createReadStream(assetPath.replace(/[\#|\?].*$/, '')) | ||
.pipe(fs.createWriteStream(newPath.replace(/[\#|\?].*$/, ''))) | ||
; | ||
}); | ||
}); | ||
} | ||
url = path.relative(options.output_css, newPath); | ||
} | ||
return url; | ||
url = path.relative(options.output_css, newPath); | ||
} | ||
return url; | ||
})) | ||
.toString(); | ||
} | ||
} | ||
}; |
{ | ||
"name": "gulp-css-rebase", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Rewrite url references in CSS and copyed CSS assets", | ||
@@ -17,5 +17,10 @@ "main": "index.js", | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"eslint": "^3.19.0" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node_modules/.bin/eslint .", | ||
"patch": "npm version patch && git push origin master --follow-tags && npm publish", | ||
"minor": "npm version minor && git push origin master --follow-tags && npm publish", | ||
"major": "npm version major && git push origin master --follow-tags && npm publish" | ||
}, | ||
@@ -27,3 +32,3 @@ "repository": { | ||
"author": "Igor Ognichenko <ognichenko.igor@gmail.com>", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -30,0 +35,0 @@ "url": "https://github.com/RobinCK/gulp-css-rebase/issues" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
38369
7
0
1