Refactor code structure

This commit is contained in:
Buu Nguyen 2015-11-10 13:23:35 -08:00
parent b7abf671ea
commit 3c6245497e
7 changed files with 15 additions and 19 deletions

View File

@ -5,15 +5,13 @@ var gulp = require('gulp')
, spawn = require('child_process').spawn
, $ = require('gulp-load-plugins')()
/**
* Public tasks
*/
// Tasks
gulp.task('clean', function () {
return pipe('./tmp', [$.clean()])
})
gulp.task('build', function (cb) {
$.runSequence('clean', 'css', 'chrome', 'opera', 'safari', 'firefox', cb)
$.runSequence('clean', 'styles', 'chrome', 'opera', 'safari', 'firefox', cb)
})
gulp.task('default', ['build'], function () {
@ -34,11 +32,10 @@ gulp.task('test', ['build'], function (cb) {
ps.on('close', cb)
})
/**
* Private tasks
*/
gulp.task('css', function () {
return pipe('./src/css/octotree.less', [$.less(), $.autoprefixer({cascade: true})], './tmp')
gulp.task('styles', function () {
return pipe('./src/styles/octotree.less',
[$.less(), $.autoprefixer({cascade: true})],
'./tmp')
})
// Chrome
@ -120,9 +117,7 @@ gulp.task('firefox:xpi', function (cb) {
$.run('cd ./tmp/firefox && cfx xpi --output-file=../../dist/firefox.xpi').exec(cb)
})
/**
* Helpers
*/
// Helpers
function pipe(src, transforms, dest) {
if (typeof transforms === 'string') {
dest = transforms
@ -157,8 +152,8 @@ function buildJs(additions, ctx) {
'./tmp/template.js',
'./src/constants.js',
'./src/adapters/adapter.js',
'./src/adapters/adapter.github.js',
'./src/adapters/adapter.gitlab.js',
'./src/adapters/github.js',
'./src/adapters/gitlab.js',
'./src/view.help.js',
'./src/view.error.js',
'./src/view.tree.js',

View File

@ -14,7 +14,7 @@ const
, GH_PJAX_SEL = '#js-repo-pjax-container'
, GH_CONTAINERS = '.container'
GitHub.prototype = new Adapter()
GitHub.prototype = Object.create(Adapter.prototype)
GitHub.prototype.constructor = GitHub
GitHub.prototype.super = Adapter.prototype

View File

@ -10,7 +10,7 @@ const
, GL_SHIFTED = 'h1.title'
, GL_PROJECT_ID = '#project_id'
GitLab.prototype = new Adapter()
GitLab.prototype = Object.create(Adapter.prototype)
GitLab.prototype.constructor = GitLab
GitLab.prototype.super = Adapter.prototype
@ -78,7 +78,7 @@ GitLab.prototype.updateLayout = function(sidebarVisible, sidebarWidth) {
}
/**
* Filter particular options for current adapter.
* Filters particular options for current adapter.
* @param {DOM Object} dom - the template which needs to be filtered.
*/
GitLab.prototype.filterOption = function(dom) {

View File

@ -263,5 +263,3 @@ a.octotree_toggle {
font-size: 13px;
}
}
@import "octotree_github";
@import "octotree_gitlab";

3
src/styles/octotree.less Normal file
View File

@ -0,0 +1,3 @@
@import "common";
@import "github";
@import "gitlab";