install gulp
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Konstantin Tarkus (@koistya)
|
||||
|
||||
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.
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
# [gulp](http://gulpjs.com)-csscomb [](http://travis-ci.org/koistya/gulp-csscomb) [](https://david-dm.org/koistya/gulp-csscomb) [](https://gratipay.com/koistya)
|
||||
|
||||
[<img src="https://rawgit.com/koistya/gulp-csscomb/master/csscomb.jpg" width="80" height="80" align="right">](http://csscomb.com)
|
||||
|
||||
> Format CSS coding style with [CSScomb](http://csscomb.com).
|
||||
|
||||
*If you have any difficulties with the output of this plugin, please use the
|
||||
[CSScomb tracker](https://github.com/csscomb/csscomb.js/issues).*
|
||||
|
||||
---
|
||||
|
||||
<p align="center"><b>🔥 Want to strengthen your core JavaScript skills and master ES6?</b><br>I would personally recommend this awesome <a href="https://es6.io/friend/konstantin">ES6 course</a> by Wes Bos.</p>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install gulp-csscomb --save-dev
|
||||
```
|
||||
|
||||
## Example 1
|
||||
|
||||
```js
|
||||
var gulp = require('gulp');
|
||||
var csscomb = require('gulp-csscomb');
|
||||
|
||||
gulp.task('styles', function() {
|
||||
return gulp.src('src/styles/main.css')
|
||||
.pipe(csscomb())
|
||||
.pipe(gulp.dest('./build/css'));
|
||||
});
|
||||
```
|
||||
|
||||
## Example 2
|
||||
|
||||
```js
|
||||
var gulp = require('gulp');
|
||||
var $ = require('gulp-load-plugins')();
|
||||
|
||||
gulp.task('styles', function() {
|
||||
return gulp.src('src/styles/bootstrap.less')
|
||||
.pipe($.less({strictMath: true}))
|
||||
.pipe($.autoprefixer([
|
||||
'Android 2.3',
|
||||
'Android >= 4',
|
||||
'Chrome >= 20',
|
||||
'Firefox >= 24', // Firefox 24 is the latest ESR
|
||||
'Explorer >= 8',
|
||||
'iOS >= 6',
|
||||
'Opera >= 12',
|
||||
'Safari >= 6']))
|
||||
.pipe($.csscomb())
|
||||
.pipe(gulp.dest('./build/css'));
|
||||
});
|
||||
```
|
||||
|
||||
If there is `.csscomb.json` file present in the same folder as the source file(s),
|
||||
or in the project root folder, `gulp-csscomb` will read config settings from it
|
||||
instead of default config.
|
||||
|
||||
You can also specify a pre-defined configuration. Ex.: `csscomb('zen')`
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT) © Konstantin Tarkus ([@koistya](https://twitter.com/koistya))
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*!
|
||||
* gulp-csscomb | https://github.com/koistya/gulp-csscomb
|
||||
* Copyright (c) Konstantin Tarkus (@koistya). See LICENSE.txt
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var Comb = require('csscomb');
|
||||
var fs = require('fs');
|
||||
var gutil = require('gulp-util');
|
||||
var path = require('path');
|
||||
var through = require('through2');
|
||||
var PluginError = gutil.PluginError;
|
||||
|
||||
// Constants
|
||||
var PLUGIN_NAME = 'gulp-csscomb';
|
||||
var SUPPORTED_EXTENSIONS = ['.css', '.sass', '.scss', '.less'];
|
||||
|
||||
// Plugin level function (dealing with files)
|
||||
function Plugin(configPath, options) {
|
||||
|
||||
if (arguments.length == 1 && typeof configPath === 'object') {
|
||||
options = configPath;
|
||||
configPath = options.configPath;
|
||||
} else if (arguments.length == 2 && typeof options === 'boolean') {
|
||||
options = { verbose: options }; // for backward compatibility
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
configPath = configPath || null;
|
||||
|
||||
var verbose = options.verbose || false;
|
||||
//var lint = options.lint || false; // TODO: Report about found issues in style sheets
|
||||
|
||||
// Create a stream through which each file will pass
|
||||
var stream = through.obj(function(file, enc, cb) {
|
||||
|
||||
if (file.isNull()) {
|
||||
// Do nothing
|
||||
} else if (file.isStream()) {
|
||||
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
|
||||
return cb();
|
||||
} else if (file.isBuffer() && SUPPORTED_EXTENSIONS.indexOf(path.extname(file.path)) !== -1) {
|
||||
|
||||
if (verbose) {
|
||||
gutil.log(PLUGIN_NAME, 'Processing ' + gutil.colors.magenta(file.path));
|
||||
}
|
||||
|
||||
if (configPath && !fs.existsSync(configPath)) {
|
||||
this.emit('error', new PluginError(PLUGIN_NAME, 'Configuration file not found: ' + gutil.colors.magenta(configPath)));
|
||||
return cb();
|
||||
}
|
||||
|
||||
configPath = Comb.getCustomConfigPath(configPath || path.join(path.dirname(file.path), '.csscomb.json'));
|
||||
var config = Comb.getCustomConfig(configPath);
|
||||
|
||||
if (verbose) {
|
||||
gutil.log(PLUGIN_NAME, 'Using configuration file ' + gutil.colors.magenta(configPath));
|
||||
}
|
||||
|
||||
var comb = new Comb(config || 'csscomb');
|
||||
var syntax = options.syntax || file.path.split('.').pop();
|
||||
|
||||
try {
|
||||
var output = comb.processString(
|
||||
file.contents.toString('utf8'), {
|
||||
syntax: syntax,
|
||||
filename: file.path
|
||||
});
|
||||
file.contents = new Buffer(output);
|
||||
} catch (err) {
|
||||
this.emit('error', new PluginError(PLUGIN_NAME, file.path + '\n' + err));
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the file goes through the next gulp plugin
|
||||
this.push(file);
|
||||
// tell the stream engine that we are done with this file
|
||||
return cb();
|
||||
});
|
||||
|
||||
// Return the file stream
|
||||
return stream;
|
||||
}
|
||||
|
||||
// Export the plugin main function
|
||||
module.exports = Plugin;
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"gulp-csscomb@3.0.8",
|
||||
"/mnt/data/Sites/anissabensalah.net/user/themes/anissabensalah"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "gulp-csscomb@3.0.8",
|
||||
"_id": "gulp-csscomb@3.0.8",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-3zSCSlgKTH0zUcHo67ateh1aibc=",
|
||||
"_location": "/gulp-csscomb",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "gulp-csscomb@3.0.8",
|
||||
"name": "gulp-csscomb",
|
||||
"escapedName": "gulp-csscomb",
|
||||
"rawSpec": "3.0.8",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.8"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gulp-csscomb/-/gulp-csscomb-3.0.8.tgz",
|
||||
"_spec": "3.0.8",
|
||||
"_where": "/mnt/data/Sites/anissabensalah.net/user/themes/anissabensalah",
|
||||
"author": {
|
||||
"name": "Konstantin Tarkus",
|
||||
"url": "@koistya"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/koistya/gulp-csscomb/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"csscomb": "^3.1.7",
|
||||
"gulp-util": "^3.0.7",
|
||||
"through2": "^2.0.1"
|
||||
},
|
||||
"description": "CSScomb is a coding style formatter for CSS.",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.9.3",
|
||||
"mocha": "^3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.9.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "http://github.com/koistya/gulp-csscomb",
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
"css",
|
||||
"csscomb",
|
||||
"lint",
|
||||
"linter",
|
||||
"preprocessor"
|
||||
],
|
||||
"licenses": {
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/koistya/gulp-csscomb/raw/master/LICENSE.txt"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"name": "gulp-csscomb",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/koistya/gulp-csscomb.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jshint index.js test.js && mocha"
|
||||
},
|
||||
"version": "3.0.8"
|
||||
}
|
||||
Reference in New Issue
Block a user