Files
yjs/gulpfile.js

149 lines
3.3 KiB
JavaScript
Raw Normal View History

2015-07-21 17:14:03 +02:00
/* eslint-env node */
2015-06-15 14:53:02 +02:00
2015-06-16 14:36:00 +02:00
/** Gulp Commands
gulp command*
[--export ModuleType]
[--name ModuleName]
[--testport TestPort]
[--testfiles TestFiles]
2015-06-16 14:36:00 +02:00
Module name (ModuleName):
Compile this to "y.js" (default)
Supported module types (ModuleType):
- amd
- amdStrict
- common
- commonStrict
- ignore (default)
- system
- umd
- umdStrict
Test port (TestPort):
2015-06-16 14:41:35 +02:00
Serve the specs on port 8888 (default)
2015-06-16 14:36:00 +02:00
Test files (TestFiles):
Specify which specs to use!
2015-06-16 14:36:00 +02:00
Commands:
- build
2015-06-16 14:36:00 +02:00
Build this library
- dev:browser
2015-06-16 14:36:00 +02:00
Watch the ./src directory.
Builds the library on changes.
2015-06-16 14:36:00 +02:00
Starts an http-server and serves the test suite on http://127.0.0.1:8888.
- dev:node
Watch the ./src directory.
Builds and specs the library on changes.
Usefull to run with node-inspector.
`node-debug $(which gulp) dev:node
2015-06-16 14:36:00 +02:00
- test:
Test this library
*/
2015-07-21 17:14:03 +02:00
var gulp = require('gulp')
var sourcemaps = require('gulp-sourcemaps')
var babel = require('gulp-babel')
var uglify = require('gulp-uglify')
var minimist = require('minimist')
var jasmine = require('gulp-jasmine')
var jasmineBrowser = require('gulp-jasmine-browser')
var concat = require('gulp-concat')
var watch = require('gulp-watch')
2015-06-17 19:16:52 +02:00
2015-06-15 14:53:02 +02:00
var options = minimist(process.argv.slice(2), {
2015-07-21 17:14:03 +02:00
string: ['export', 'name', 'testport', 'testfiles'],
2015-06-16 14:36:00 +02:00
default: {
2015-07-21 17:14:03 +02:00
export: 'ignore',
name: 'y.js',
testport: '8888',
testfiles: 'src/**/*.js'
2015-06-16 14:36:00 +02:00
}
2015-07-21 17:14:03 +02:00
})
var polyfills = [
'./node_modules/gulp-babel/node_modules/babel-core/node_modules/regenerator/runtime.js'
]
var concatOrder = [
'y.js',
'Connector.js',
'OperationStore.js',
'Struct.js',
'Utils.js',
'OperationStores/RedBlackTree.js',
'OperationStores/Memory.js',
'OperationStores/IndexedDB.js',
'Connectors/Test.js',
'Connectors/WebRTC.js',
'Types/Array.js',
'Types/Map.js',
'Types/TextBind.js'
]
2015-06-15 14:53:02 +02:00
var files = {
2015-09-28 23:54:56 +02:00
src: polyfills.concat(concatOrder.map(function (f) {
return 'src/' + f
})),
2015-09-28 23:54:56 +02:00
test: ['Helper.spec.js'].concat(concatOrder.map(function (f) {
return 'build/' + f
2015-09-28 23:54:56 +02:00
}).concat(['build/**/*.spec.js']))
2015-07-21 17:14:03 +02:00
}
gulp.task('build:deploy', function () {
2015-09-28 23:54:56 +02:00
gulp.src(files.src)
2015-07-21 17:14:03 +02:00
.pipe(sourcemaps.init())
.pipe(concat('y.js'))
2015-07-21 17:14:03 +02:00
.pipe(babel({
loose: 'all',
modules: 'ignore',
experimental: true
}))
.pipe(uglify())
2015-09-28 23:54:56 +02:00
.pipe(sourcemaps.write('.'))
2015-07-21 17:14:03 +02:00
.pipe(gulp.dest('.'))
})
gulp.task('build:test', function () {
2015-09-11 18:35:32 +02:00
gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
2015-07-21 17:14:03 +02:00
loose: 'all',
modules: 'ignore',
2015-09-11 18:35:32 +02:00
blacklist: 'regenerator',
experimental: true
}))
2015-09-11 18:35:32 +02:00
.pipe(sourcemaps.write())
2015-07-21 17:14:03 +02:00
.pipe(gulp.dest('build'))
})
2015-06-15 14:53:02 +02:00
gulp.task('dev:node', ['test'], function () {
gulp.watch('src/**/*.js', ['test'])
2015-07-21 17:14:03 +02:00
})
gulp.task('dev:browser', ['build:test'], function () {
gulp.watch('src/**/*.js', ['build:test'])
gulp.src(files.test)
.pipe(watch(['build/**/*.js']))
2015-06-16 14:36:00 +02:00
.pipe(jasmineBrowser.specRunner())
2015-07-21 17:14:03 +02:00
.pipe(jasmineBrowser.server({port: options.testport}))
})
2015-06-15 14:53:02 +02:00
gulp.task('dev', ['build:test'], function () {
gulp.start('dev:browser')
gulp.start('dev:node')
})
gulp.task('test', ['build:test'], function () {
return gulp.src(files.test)
2015-09-11 18:35:32 +02:00
.pipe(jasmine({
verbose: true,
includeStuckTrace: true
}))
})
gulp.task('default', ['test'])