Skip to content

Commit

Permalink
update for npm compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-bateman committed Oct 22, 2014
1 parent d188c11 commit 06a4b75
Show file tree
Hide file tree
Showing 275 changed files with 41,121 additions and 0 deletions.
136 changes: 136 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
//var gulp = require('gulp');
//var browserify = require('browserify');
//var source = require('vinyl-source-stream');
//


//var gulp = require('gulp');
//var glob = require('glob');
//var browserify = require('browserify');
//var source = require('vinyl-source-stream');
//
//gulp.task('browserify', function(){
// var testFiles = glob.sync('./build/away/**/*.js');
// return browserify({
// debug: true,
// entries: testFiles,
// paths: ['./build/away']
// })
// .bundle()
// .pipe(source('away.js'))
// .pipe(gulp.dest('./build'));
//});
//
//gulp.task('default', ['browserify']);

var concat = require('gulp-concat');
var gulp = require('gulp');
var changed = require('gulp-changed');
var glob = require('glob');
var path = require('path');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var map = require('vinyl-map');
var exorcist = require('exorcist');
var sourcemaps = require('gulp-sourcemaps');

var typescript = require('gulp-typescript');

//var project = {
// declaration: true,
// sourcemap: true,
// noResolve: false,
// target: 'ES5',
// module: 'commonjs'
//};
//
//gulp.task('compile', function() {
// return gulp.src(['./lib/**/*.ts'])
// //.pipe(changed('./out/', {extension:'.js', hasChanged: changed.compareLastModifiedTime}))
// .pipe(tsc(project))
// .pipe(gulp.dest('out/'));
//});
//
//gulp.task('watch', ['scripts'], function() {
// gulp.watch('lib/**/*.ts', ['scripts']);
//});

gulp.task('compile', function() {
var tsProject = typescript.createProject({
declarationFiles: true,
noExternalResolve: true,
target: 'ES5',
module: 'commonjs'
});

var ambientWrap = map(function(code, filename) {
code = code.toString();
code = 'declare module "' + path.relative('../', filename.slice(0,-5)) + '" {\n\t'
+ code.split('declare ').join('').split('\n').join('\n\t') + "\n"
+ '}';
return code;
});

var tsResult = gulp.src(['./lib/**/*.ts', './node_modules/awayjs-**/build/*.d.ts'])
.pipe(sourcemaps.init())
.pipe(typescript(tsProject));

tsResult.dts
.pipe(ambientWrap)
.pipe(concat('awayjs-renderergl.d.ts'))
.pipe(gulp.dest('./build'));

return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('./lib'));
});

gulp.task('watch', ['package'], function() {
gulp.watch('./lib/**/*.ts', ['package']);
});

gulp.task('package', ['compile'], function(callback){
var b = browserify({
debug: true,
paths: ['../']
});

glob('./node_modules/awayjs-**/lib/**/*.js', {}, function (error, files) {
files.forEach(function (file) {
b.external(file);
});
});

glob('./lib/**/*.js', {}, function (error, files) {

files.forEach(function (file) {
b.require(file, {expose:path.relative('../', file.slice(0,-3))});
});

b.bundle()
.pipe(exorcist('./build/awayjs-renderergl.js.map'))
.pipe(source('awayjs-renderergl.js'))
.pipe(gulp.dest('./build'))
.on('end', callback);
});
});


gulp.task('tests', function () {

var tsProject = typescript.createProject({
declarationFiles: true,
noExternalResolve: true,
target: 'ES5',
module: 'commonjs'
});

var tsResult = gulp.src(['./tests/**/*.ts', './node_modules/awayjs-**/build/*.d.ts', './build/awayjs-renderergl.d.ts'])
//.pipe(changed('./tests', {extension:'.js', hasChanged: changed.compareLastModifiedTime}))
.pipe(sourcemaps.init())
.pipe(typescript(tsProject));

return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('./tests'));
});
Loading

0 comments on commit 06a4b75

Please sign in to comment.