Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
chore(gulp): rename all providers, add compat task to build
Browse files Browse the repository at this point in the history
Addresses #521
  • Loading branch information
frapontillo authored and mgcrea committed Sep 24, 2015
1 parent 98c50c6 commit d063b44
Showing 1 changed file with 46 additions and 23 deletions.
69 changes: 46 additions & 23 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var config = require('ng-factory').use(gulp, {
src: {
docsViews: '*/docs/{,*/}*.tpl.{html,jade}'
},
bower: {
bower: {
exclude: /jquery|js\/bootstrap|\.less/
}
});
Expand All @@ -17,41 +17,64 @@ var config = require('ng-factory').use(gulp, {

gulp.task('serve', gulp.series('ng:serve'));

var del = require('del');
var path = require('path');
gulp.task('build', gulp.series('ng:build', function afterBuild(done) {
var paths = config.paths;
// Delete useless module.* build files
del(path.join(paths.dest, 'module.*'), done);
}));

gulp.task('pages', gulp.series('ng:pages', function afterPages(done) {
var paths = config.docs;
return gulp.src(['bower_components/highlightjs/styles/github.css'], {cwd: paths.cwd, base: paths.cwd})
.pipe(gulp.dest(paths.dest));
}));

var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');

gulp.task('compat', function() {
var paths = config.paths;
var providers = [
'$affix', '$alert', '$aside', '$button', '$collapse', '$datepicker', 'datepickerViews',
'$dropdown', '$dateFormatter', '$dateParser', 'debounce', 'throttle', 'dimensions',
'$parseOptions', '$$rAF', '$modal', '$navbar', '$popover', '$scrollspy', '$select', '$tab',
'$timepicker', '$tooltip', '$typeahead'
];
var compatProviders = providers.map(function(provider) {
var prependBs = function(what) {
var start = what.lastIndexOf('$') + 1;
if (start < 1) {
start = 0;
}
return what.substr(0, start) + 'bs' + what.substr(start, 1).toUpperCase() +
what.substring(start + 1, what.length);
};
return {
from: provider,
to: prependBs(provider)
}
});
return gulp.src(paths.dest + '/angular-strap.js')
.pipe(ngAnnotate({
add: true,
remove: true,
rename: [
{from: '$tooltip', to: '$bsTooltip'},
{from: '$button', to: '$bsButton'},
{from: '$modal', to: '$bsModal'}
]
rename: compatProviders
}))
.pipe(rename(function(file) {
file.extname = '.compat.js';
}))
.pipe(rename(function(file) { file.extname = '.compat.js'; }))
.pipe(gulp.dest(paths.dest))
.pipe(uglify({output: {indent_level: 2, quote_style: 1}}))
.pipe(rename(function(file) { file.extname = '.min.js'; }))
.pipe(rename(function(file) {
file.extname = '.min.js';
}))
.pipe(gulp.dest(paths.dest))
})
});

var del = require('del');
var path = require('path');

gulp.task('build', gulp.series('ng:build', 'compat', function afterBuild(done) {
var paths = config.paths;
// Delete useless module.* build files
del(path.join(paths.dest, 'module.*'), done);
}));

gulp.task('pages', gulp.series('ng:pages', function afterPages(done) {
var paths = config.docs;
return gulp.src(['bower_components/highlightjs/styles/github.css'],
{cwd: paths.cwd, base: paths.cwd})
.pipe(gulp.dest(paths.dest));
}));

//
// Tests
Expand Down

0 comments on commit d063b44

Please sign in to comment.