You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.0 KiB
80 lines
2.0 KiB
10 years ago
|
#!/usr/bin/env node
|
||
|
|
||
|
'use strict';
|
||
|
|
||
10 years ago
|
var version = require('./version.json');
|
||
10 years ago
|
var path = require('path');
|
||
|
|
||
|
var del = require('del');
|
||
|
var gulp = require('gulp');
|
||
|
var browserify = require('browserify');
|
||
|
var jshint = require('gulp-jshint');
|
||
|
var uglify = require('gulp-uglify');
|
||
|
var rename = require('gulp-rename');
|
||
|
var source = require('vinyl-source-stream');
|
||
|
var exorcist = require('exorcist');
|
||
|
var bower = require('bower');
|
||
10 years ago
|
var streamify = require('gulp-streamify');
|
||
10 years ago
|
var replace = require('gulp-replace');
|
||
10 years ago
|
|
||
|
var DEST = './dist/';
|
||
10 years ago
|
var src = 'index';
|
||
|
var dst = 'ethereum';
|
||
|
|
||
|
var browserifyOptions = {
|
||
|
debug: true,
|
||
10 years ago
|
insert_global_vars: false, // jshint ignore:line
|
||
10 years ago
|
detectGlobals: false,
|
||
|
bundleExternal: false
|
||
10 years ago
|
};
|
||
|
|
||
10 years ago
|
gulp.task('versionReplace', function(){
|
||
|
gulp.src(['./package.json'])
|
||
|
.pipe(replace(/\"version\"\: \"(.{5})\"/, '"version": "'+ version.version + '"'))
|
||
|
.pipe(gulp.dest('./'));
|
||
|
gulp.src(['./package.js'])
|
||
|
.pipe(replace(/version\: \'(.{5})\'/, "version: '"+ version.version + "'"))
|
||
|
.pipe(gulp.dest('./'));
|
||
|
});
|
||
|
|
||
10 years ago
|
gulp.task('bower', function(cb){
|
||
10 years ago
|
bower.commands.install().on('end', function (installed){
|
||
|
console.log(installed);
|
||
|
cb();
|
||
|
});
|
||
10 years ago
|
});
|
||
|
|
||
10 years ago
|
gulp.task('clean', ['lint'], function(cb) {
|
||
10 years ago
|
del([ DEST ], cb);
|
||
10 years ago
|
});
|
||
|
|
||
10 years ago
|
gulp.task('lint', function(){
|
||
10 years ago
|
return gulp.src(['./*.js', './lib/*.js'])
|
||
|
.pipe(jshint())
|
||
|
.pipe(jshint.reporter('default'));
|
||
10 years ago
|
});
|
||
|
|
||
|
gulp.task('build', ['clean'], function () {
|
||
10 years ago
|
return browserify(browserifyOptions)
|
||
|
.require('./' + src + '.js', {expose: 'web3'})
|
||
|
.add('./' + src + '.js')
|
||
|
.bundle()
|
||
|
.pipe(exorcist(path.join( DEST, dst + '.js.map')))
|
||
|
.pipe(source(dst + '.js'))
|
||
|
.pipe(gulp.dest( DEST ))
|
||
|
.pipe(streamify(uglify()))
|
||
|
.pipe(rename(dst + '.min.js'))
|
||
|
.pipe(gulp.dest( DEST ));
|
||
10 years ago
|
});
|
||
|
|
||
|
gulp.task('watch', function() {
|
||
10 years ago
|
gulp.watch(['./lib/*.js'], ['lint', 'build']);
|
||
10 years ago
|
});
|
||
|
|
||
10 years ago
|
gulp.task('dev', ['versionReplace','bower', 'lint', 'build']);
|
||
10 years ago
|
gulp.task('default', ['dev']);
|
||
10 years ago
|
|
||
10 years ago
|
|
||
|
gulp.task('version', ['versionReplace']);
|
||
|
|