Files
yjs/gulpfile.js

150 lines
3.7 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:
Build this library
- develop:
Watch the ./src directory.
2015-06-16 14:41:35 +02:00
Builds and specs 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.
- build_test:
Builds the test suite
- 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-09-09 20:29:39 +02:00
var ignore = require('gulp-ignore')
2015-06-15 14:53:02 +02:00
2015-06-17 19:16:52 +02:00
var polyfills = [
2015-07-21 17:14:03 +02:00
'./node_modules/gulp-babel/node_modules/babel-core/node_modules/regenerator/runtime.js'
]
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
})
2015-07-25 16:28:05 +00:00
var yfiles = polyfills.concat(['src/y.js', 'src/Connector.js', 'src/OperationStore.js', 'src/Struct.js', 'src/Utils.js',
'src/OperationStores/RedBlackTree.js', 'src/Memory.js', 'src/**/*.js'])
2015-06-15 14:53:02 +02:00
var files = {
2015-07-25 16:28:05 +00:00
y: yfiles.concat(['!src/**/*.spec.js']),
test: yfiles.concat([options.testfiles]),
2015-07-21 17:14:03 +02:00
build_test: ['build_test/y.js']
}
2015-07-21 17:14:03 +02:00
gulp.task('build', function () {
/*
return gulp.src(files.y)
2015-06-15 14:53:02 +02:00
.pipe(sourcemaps.init())
2015-06-16 14:36:00 +02:00
.pipe(concat(options.name))
2015-06-15 14:53:02 +02:00
.pipe(babel({
loose: "all",
2015-07-14 22:39:01 +02:00
modules: options.export,
// blacklist: "regenerator" // you can't uglify when regenerator is blacklisted!
2015-06-15 14:53:02 +02:00
}))
.pipe(uglify())
.pipe(sourcemaps.write("."))
2015-07-14 22:39:01 +02:00
.pipe(gulp.dest("."));*/
return gulp.src(files.y)
2015-07-21 17:14:03 +02:00
.pipe(sourcemaps.init())
.pipe(concat(options.name))
.pipe(babel({
loose: 'all',
modules: 'ignore',
optional: ['es7.asyncFunctions'],
blacklist: ['regenerator'],
experimental: true
}))
2015-09-09 20:29:39 +02:00
.pipe(sourcemaps.write('.'))
2015-07-21 17:14:03 +02:00
.pipe(gulp.dest('.'))
})
gulp.task('test', function () {
return gulp.src(files.test)
.pipe(sourcemaps.init())
2015-07-21 17:14:03 +02:00
.pipe(concat('jasmine'))
.pipe(babel({
2015-07-21 17:14:03 +02:00
loose: 'all',
optional: ['es7.asyncFunctions'],
modules: 'ignore',
experimental: true
}))
.pipe(uglify())
2015-09-09 20:29:39 +02:00
.pipe(sourcemaps.write('.'))
2015-07-21 17:14:03 +02:00
.pipe(gulp.dest('build'))
2015-09-09 20:29:39 +02:00
.pipe(ignore.include('*.js'))
2015-06-16 14:36:00 +02:00
.pipe(jasmine({
verbose: true,
includeStuckTrace: true
2015-07-21 17:14:03 +02:00
}))
})
2015-06-15 14:53:02 +02:00
2015-07-21 17:14:03 +02:00
gulp.task('build_jasmine_browser', function () {
gulp.src(files.test)
2015-07-21 17:14:03 +02:00
.pipe(sourcemaps.init())
.pipe(concat('jasmine_browser.js'))
.pipe(babel({
loose: 'all',
modules: 'ignore',
2015-09-09 20:29:39 +02:00
// optional: ['es7.asyncFunctions'],
blacklist: "regenerator",
//experimental: true
2015-07-21 17:14:03 +02:00
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build'))
})
gulp.task('develop', ['build_jasmine_browser'], function () {
2015-07-21 17:14:03 +02:00
gulp.watch(files.test, ['build_jasmine_browser'])
// gulp.watch(files.test, ["test"])
gulp.watch(files.test, ['build'])
return gulp.src('build/jasmine_browser.js')
.pipe(watch('build/jasmine_browser.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
2015-07-21 17:14:03 +02:00
gulp.task('default', ['build', 'test'])