Skip to content

Commit ffce548

Browse files
author
Shuwen Qian
committed
IIFE patch WIP
1 parent 7c3f60f commit ffce548

3 files changed

Lines changed: 48 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
build_docs/
55
.grunt
66
.publish
7+
.patched_components/

Gulpfile.js

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,39 @@ var through = require('through2');
3535
var hogan = require('hogan.js');
3636
var header = require('gulp-header');
3737
var base64 = require('gulp-base64');
38+
var minimist = require('minimist');
39+
var tap = require('gulp-tap');
40+
var replace = require('gulp-replace-path');
3841

3942
var SRC = 'src/';
4043
var BUILD = 'build/';
4144
var BUILD_DOCS = 'build_docs/';
4245
var DIST = 'dist/';
4346
var TEMPLATES = 'gulp/templates/'; //TODO swap to gulp
4447

48+
var LIB = ['bower_components/moment/**/*.js'];
49+
4550
/** BUILD **/
4651

52+
gulp.task('patch-lib', function() {
53+
var paths = LIB.reduce(function(fileList, pattern) {
54+
return fileList.concat(glob.sync(pattern));
55+
}, []);
56+
console.log(paths);
57+
58+
gulp.src(path.join(__dirname, 'bower_components/**'))
59+
.pipe(tap(function(file, t) {
60+
if(paths.indexOf(file.path) > -1) {
61+
return t.through(wrap("(function(define, require) { {{{contents}}} })();",{},{engine:"hogan"}).on('error',console.error));
62+
}
63+
}))
64+
.pipe(gulp.dest( path.join(__dirname, '.patched_components') ));
65+
});
66+
67+
gulp.task('replace-lib', function() {
68+
69+
});
70+
4771
gulp.task('clean', function() {
4872
return del([BUILD + '**', BUILD_DOCS+ '**', DIST+ '**']);
4973
});
@@ -383,30 +407,31 @@ gulp.task('watch', function () {
383407

384408
/** DEPLOY **/
385409

410+
function inc(version) {
411+
if(!version) version = 'patch';
412+
return gulp.src(['package.json', 'bower.json'])
413+
.pipe(bump({type: version}))
414+
.pipe(gulp.dest(__dirname));
415+
}
416+
417+
gulp.task('release', function() {
418+
var argv = minimist(process.argv.slice(3)),
419+
version = argv.v || argv.version,
420+
valid = ['major', 'minor', 'patch'];
421+
422+
if(valid.indexOf(version) > -1) {
423+
run(inc(version), 'build:prod', 'changelog', 'stage-release', 'tag-release');
424+
}
425+
});
426+
386427
gulp.task('release:major', function() {
387-
run('build:prod', 'bump:major', 'changelog', 'stage-release', 'tag-release');
428+
run(inc('major'), 'build:prod', 'changelog', 'stage-release', 'tag-release');
388429
});
389430
gulp.task('release:minor', function() {
390-
run('build:prod', 'bump:minor', 'changelog', 'stage-release', 'tag-release');
431+
run(inc('minor'), 'build:prod', 'changelog', 'stage-release', 'tag-release');
391432
});
392433
gulp.task('release:patch', function() {
393-
run('build:prod', 'bump:patch', 'changelog', 'stage-release', 'tag-release');
394-
});
395-
396-
gulp.task('bump:major', function(){
397-
return gulp.src(['package.json', 'bower.json'])
398-
.pipe(bump({type: 'major'}))
399-
.pipe(gulp.dest('./'));
400-
});
401-
gulp.task('bump:minor', function(){
402-
return gulp.src(['package.json', 'bower.json'])
403-
.pipe(bump({type: 'minor'}))
404-
.pipe(gulp.dest('./'));
405-
});
406-
gulp.task('bump:patch', function(){
407-
return gulp.src(['package.json', 'bower.json'])
408-
.pipe(bump({type: 'patch'}))
409-
.pipe(gulp.dest('./'));
434+
run(inc('patch'), 'build:prod', 'changelog', 'stage-release', 'tag-release');
410435
});
411436

412437
gulp.task('changelog', function() {

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@
3434
"gulp-minify-inline": "^0.2.0",
3535
"gulp-postcss": "^6.0.1",
3636
"gulp-rename": "^1.2.2",
37+
"gulp-replace-path": "^0.4.0",
3738
"gulp-sass": "^2.1.0",
3839
"gulp-tag-version": "^1.3.0",
40+
"gulp-tap": "^0.1.3",
3941
"gulp-util": "^3.0.7",
4042
"gulp-vulcanize": "^6.0.1",
4143
"gulp-wrap": "^0.11.0",
4244
"hogan.js": "^3.0.2",
4345
"marked": "^0.3.3",
4446
"merge-stream": "^1.0.0",
47+
"minimist": "^1.2.0",
4548
"run-sequence": "^1.1.4",
4649
"through2": "^2.0.1"
4750
}

0 commit comments

Comments
 (0)