Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": false,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"newcap": true,
"noarg": true,
"quotmark": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": true,
"smarttabs": true
}
159 changes: 159 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
'use strict';

var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
util = require('gulp-util'),
runSequence = require('run-sequence').use(gulp),
del = require('del'),
fs = require('fs'),
semver = require('semver'),
argv = require('yargs').argv;

var config = {
source: ['./src/editableCell.js'],
target: './out',
externals: ['knockout', 'jquery'],
increment: argv.inc || 'patch',
dryRun: argv.dryrun || false
};

gulp.task('default', function(done) {
return runSequence('clean', 'bundle', 'lint', 'test', done);
});

gulp.task('clean', function(done) {
del(config.target, {
force: true
}, done);
});

gulp.task('lint', function() {
return gulp.src(['./src/**/*.+(js)', './Gulpfile.js'])
.pipe($.jshint('.jshintrc'))
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.jshint.reporter('fail'));
});

gulp.task('bundle', function() {
browserify(config.source, {
debug: false,
standalone: 'editableCell',
silent: true
})
.external(config.externals)
.on('log', function(msg) {
util.log(util.colors.yellow('[Browserify]', msg));
})
.on('error', function(err) {
util.log(util.colors.red('[Browserify]', err));
})
.bundle()
.pipe(source('editableCell.js'))
.pipe($.replace('define(e);', 'define([\'knockout\'],e);'))
.pipe(buffer())
.pipe(gulp.dest(config.target))
.pipe($.sourcemaps.init({
loadMaps: true
}))
.pipe($.uglify())
.pipe($.rename({
suffix: '.min'
}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest(config.target));
});

gulp.task('_bundle_tests', function(done) {
browserify('./test/index.js', {
silent: true,
baseDir: './'
})
.on('error', function(err) {
util.log(util.colors.red('[Browserify]', err));
})
.bundle()
.pipe(source('tests.js'))
.pipe(buffer())
.pipe(gulp.dest(config.target));

done();
});

gulp.task('_test', function(done) {
var stream = $.mochaPhantomjs();
stream.on('phantomjsExit', function() {
done();
});

return gulp.src(['./test/*.html'])
.pipe(stream)
.on('error', function(err) {
util.log(util.colors.red('[Err]', err));
this.emit('end');
});
});

gulp.task('test', function(done) {
return runSequence('_bundle_tests', ['_test'], done);
});

gulp.task('bump', function() {
var pkg = getPackageJson(),
newVer = semver.inc(pkg.version, config.increment);

return gulp.src('./package.json')
.pipe($.bump({ version: newVer }))
.pipe(gulp.dest('./'))
.pipe($.if(!config.dryRun, $.git.commit('Bumped version to v' + newVer)));
});

gulp.task('_add_output_folder', function() {
return gulp.src(['./out/*'])
.pipe($.git.add({ args: '-f'}));
});

gulp.task('_publish', function(done) {
/*
git add -f out/*
git checkout head
git commit -m "Version {version} for distribution"
git tag -a v{version} -m "Add tag v{verson}"
git checkout master
git push origin --tags
*/
var ver = getPackageJson().version,
opt = { quiet: true };

$.git.checkout('head', function(err){
if (err) { throw err; }

$.git.commit('Version ' + ver + ' for distribution', opt);

$.git.tag('v' + ver, 'Add tag v' + ver, opt, function(err) {
if (err) { throw err; }

$.git.reset('master', { args: '--hard', quiet: true }, function(err) {
if (err) { throw err; }

if (!config.dryRun) {
$.git.push('origin', 'master', { args: '--tags', quiet: true }, function(err){
if (err) { throw err; }
done();
});
}
});
});

});
});

gulp.task('release', function(done) {
runSequence('default', 'bump', '_add_output_folder', '_publish', done);
});

function getPackageJson() {
return JSON.parse(fs.readFileSync('./package.json', 'utf8'));
}
74 changes: 0 additions & 74 deletions make.js

This file was deleted.

1 change: 0 additions & 1 deletion out/.gitignore

This file was deleted.

29 changes: 25 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,40 @@
"url": "https://github.com/gnab/editableCell.git"
},
"devDependencies": {
"browserify": "^6.3.3",
"browserify": "^9.0.3",
"del": "^1.1.1",
"events": "^1.0.2",
"gulp": "^3.8.11",
"gulp-bump": "^0.2.1",
"gulp-concat": "^2.5.2",
"gulp-derequire": "^2.0.0",
"gulp-git": "^1.0.0",
"gulp-if": "^1.2.5",
"gulp-jshint": "^1.9.2",
"gulp-load-plugins": "^0.8.0",
"gulp-mocha-phantomjs": "^0.5.3",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.5.3",
"gulp-sourcemaps": "^1.3.0",
"gulp-uglify": "^1.1.0",
"gulp-util": "^3.0.4",
"inherits": "^2.0.1",
"jquery": "^2.1.1",
"jshint": "^2.5.10",
"jshint-stylish": "^1.0.1",
"knockout": "^3.2.0",
"mocha": "^2.0.1",
"mocha-phantomjs": "^3.5.1",
"phantomjs": "^1.9.12",
"shelljs": "^0.3.0",
"run-sequence": "^1.0.2",
"semver": "^4.3.1",
"should": "^4.3.0",
"uglify-js": "^2.4.15"
"uglify-js": "^2.4.15",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0",
"yargs": "^3.3.1"
},
"scripts": {
"test": "node make test"
"test": "gulp bundle test"
}
}
2 changes: 1 addition & 1 deletion src/editableCell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"option strict";
var koBindingHandlers = require('./ko'),
var koBindingHandlers = require('./ko'), //jshint ignore:line
events = require('./events');

exports.selectCell = function (cell) {
Expand Down
2 changes: 2 additions & 0 deletions src/ko/editableCellBinding.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global $ */

"option strict";
var utils = require('./utils'),
events = require('../events'),
Expand Down
2 changes: 1 addition & 1 deletion src/ko/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"option strict";
var polyfill = require('../polyfill');
var polyfill = require('../polyfill'); // jshint ignore:line
var ko = require('./wrapper');

// Knockout binding handlers
Expand Down
1 change: 1 addition & 0 deletions src/ko/wrapper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global ko */
if (typeof ko !== 'undefined') {
module.exports = ko;
}
Expand Down
6 changes: 3 additions & 3 deletions src/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var SelectionView = require('./selectionView'),
SelectionRange = require('./selectionRange'),
EventEmitter = require('events').EventEmitter,
polyfill = require('./polyfill'),
polyfill = require('./polyfill'), // jshint ignore: line
events = require('./events'),
ko = require('./ko/wrapper'),
inherits = require('inherits');
Expand Down Expand Up @@ -160,8 +160,8 @@ Selection.prototype.endEditingCell = function(cell) {
};

Selection.prototype.getRowByIndex = function(index, originTable) {
if (isNaN(index)) return null;
if (isNaN(index)) { return null; }

var targetTable = originTable || this.table;

// Check if we're moving out of table
Expand Down
9 changes: 5 additions & 4 deletions src/selectionRange.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"option strict";
var EventEmitter = require('events').EventEmitter,
polyfill = require('./polyfill'),
polyfill = require('./polyfill'), // jshint ignore:line
inherits = require('inherits');

module.exports = SelectionRange;
Expand Down Expand Up @@ -126,8 +126,7 @@ SelectionRange.prototype.getCellInDirection = function (originCell, direction) {
};

SelectionRange.prototype.getSelectableCellInDirection = function (originCell, direction) {
var lastCell,
cell = originCell;
var cell = originCell;

while (cell) {
cell = this.getCellInDirection(cell, direction);
Expand All @@ -141,7 +140,9 @@ SelectionRange.prototype.getSelectableCellInDirection = function (originCell, di
};

SelectionRange.prototype.getLastSelectableCellInDirection = function (originCell, direction) {
var nextCell = originCell;
var nextCell = originCell,
cell = nextCell;

do {
cell = nextCell;
nextCell = this.getSelectableCellInDirection(cell, direction);
Expand Down
10 changes: 1 addition & 9 deletions src/selectionView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"option strict";
var polyfill = require('./polyfill');
var polyfill = require('./polyfill'); // jshint ignore: line

module.exports = SelectionView;

Expand Down Expand Up @@ -159,14 +159,6 @@ SelectionView.prototype.show = function () {
}
};

function resolve (value) {
if (typeof value === 'function') {
return value();
}

return value;
}

SelectionView.prototype.hide = function () {
this.element.style.display = 'none';
};
Expand Down
Loading