Skip to content

Commit

Permalink
Merge pull request django-cms#4 from Flight/feature/cms-652-add-js-li…
Browse files Browse the repository at this point in the history
…nting-to-travis-2

Readme updated, jscs watcher added
  • Loading branch information
Flight committed Nov 12, 2015
2 parents bd81209 + bf2947c commit 49882a9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env:
- DJANGO="https://github.com/django/django/archive/master.zip" EASY_THUMBNAILS="easy-thumbnails>2.0"

script:
- if [[ $TRAVIS_PYTHON_VERSION = "2.6" && $FRONTEND = "true" ]]; then gulp ci; else coverage run --rcfile=coverage.rc test_settings.py; fi;
- if [[ $TRAVIS_PYTHON_VERSION = "2.6" && $FRONTEND = "true" ]]; then gulp lint; else coverage run --rcfile=coverage.rc test_settings.py; fi;

after_success:
- coveralls --config_file=coverage.rc
Expand Down
33 changes: 28 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,45 @@ To started development fron-end part of ``django-filer`` simply install all the

``npm install``

To compile and watch scss and run jshint and jscs watchers:
``gulp``

To compile scss to css:

``gulp scss`` or ``gulp compile``
``gulp sass``

To run scss watcher:
To run sass watcher:

``gulp scss:watch``
``gulp sass:watch``

To lint javascript code:
To run javascript linting and code styling analysis:

``gulp lint``

To run javascript linter watcher:
To run javascript linting and code styling analysis watcher:

``gulp lint:watch``

To run javascript linting:

``gulp jshint``

To run javascript linter watcher:

``gulp jshint:watch``

To run javascript code style analysis:

``gulp jscs``

To run javascript code style analysis watcher:

``gulp jscs:watch``

To fix javascript code style errors:

``gulp jscs:fix``


.. _Django: http://djangoproject.com
.. _django-polymorphic: https://github.com/chrisglass/django_polymorphic
Expand Down
46 changes: 28 additions & 18 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,70 @@ var stylish = require('jshint-stylish');

var PROJECT_ROOT = __dirname;
var PROJECT_PATH = {
'scss': PROJECT_ROOT + '/filer/private/sass/',
'sass': PROJECT_ROOT + '/filer/private/sass/',
'css': PROJECT_ROOT + '/filer/static/filer/css/',
'js': PROJECT_ROOT + '/filer/static/filer/js/'
};

var PROJECT_PATTERNS = {
'scss': PROJECT_PATH.scss + '**/*.scss',
'sass': PROJECT_PATH.sass + '**/*.scss',
'lint': [
PROJECT_PATH.js + '**/*.js',
PROJECT_ROOT + '/gulpfile.js'
]
};

// #############################################################################
// SCSS
gulp.task('scss', function () {
gulp.src(PROJECT_PATTERNS.scss)
// sass
gulp.task('sass', function () {
gulp.src(PROJECT_PATTERNS.sass)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(sourcemaps.write('/maps'))
.pipe(gulp.dest(PROJECT_PATH.css));
});

gulp.task('scss:watch', function () {
gulp.watch(PROJECT_PATTERNS.scss, ['scss']);
gulp.task('sass:watch', function () {
gulp.watch(PROJECT_PATTERNS.sass, ['sass']);
});

// #############################################################################
// LINTING
gulp.task('jscs', function () {
return gulp.src(PROJECT_PATTERNS.lint)
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'));
});

gulp.task('jscs:fix', function () {
return gulp.src(PROJECT_PATH.js + '**/*.js')
.pipe(jscs({fix: true}))
.pipe(gulp.dest(PROJECT_PATH.js));
});

gulp.task('jscs', function () {
return gulp.src(PROJECT_PATTERNS.lint)
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'));
gulp.task('jscs:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['jscs']);
});

gulp.task('lint', function () {
gulp.task('jshint', function () {
return gulp.src(PROJECT_PATTERNS.lint)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});

gulp.task('lint:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['lint', 'jscs']);
gulp.task('jshint:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['jshint']);
});

gulp.task('js', ['jshint', 'jscs']);

gulp.task('js:watch', function () {
gulp.watch(PROJECT_PATTERNS.lint, ['js']);
});

gulp.task('compile', ['scss']);
gulp.task('watch', ['scss:watch', 'lint:watch']);
gulp.task('ci', ['lint', 'jscs']);
gulp.task('watch', ['sass:watch', 'js:watch']);
gulp.task('lint', ['js']);
gulp.task('default', ['js', 'sass', 'js:watch', 'sass:watch']);

0 comments on commit 49882a9

Please sign in to comment.