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

Commit d063b44

Browse files
frapontillomgcrea
authored andcommitted
chore(gulp): rename all providers, add compat task to build
Addresses #521
1 parent 98c50c6 commit d063b44

File tree

1 file changed

+46
-23
lines changed

1 file changed

+46
-23
lines changed

gulpfile.js

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var config = require('ng-factory').use(gulp, {
77
src: {
88
docsViews: '*/docs/{,*/}*.tpl.{html,jade}'
99
},
10-
bower: {
10+
bower: {
1111
exclude: /jquery|js\/bootstrap|\.less/
1212
}
1313
});
@@ -17,41 +17,64 @@ var config = require('ng-factory').use(gulp, {
1717

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

20-
var del = require('del');
21-
var path = require('path');
22-
gulp.task('build', gulp.series('ng:build', function afterBuild(done) {
23-
var paths = config.paths;
24-
// Delete useless module.* build files
25-
del(path.join(paths.dest, 'module.*'), done);
26-
}));
27-
28-
gulp.task('pages', gulp.series('ng:pages', function afterPages(done) {
29-
var paths = config.docs;
30-
return gulp.src(['bower_components/highlightjs/styles/github.css'], {cwd: paths.cwd, base: paths.cwd})
31-
.pipe(gulp.dest(paths.dest));
32-
}));
33-
3420
var ngAnnotate = require('gulp-ng-annotate');
3521
var rename = require('gulp-rename');
3622
var uglify = require('gulp-uglify');
23+
3724
gulp.task('compat', function() {
3825
var paths = config.paths;
26+
var providers = [
27+
'$affix', '$alert', '$aside', '$button', '$collapse', '$datepicker', 'datepickerViews',
28+
'$dropdown', '$dateFormatter', '$dateParser', 'debounce', 'throttle', 'dimensions',
29+
'$parseOptions', '$$rAF', '$modal', '$navbar', '$popover', '$scrollspy', '$select', '$tab',
30+
'$timepicker', '$tooltip', '$typeahead'
31+
];
32+
var compatProviders = providers.map(function(provider) {
33+
var prependBs = function(what) {
34+
var start = what.lastIndexOf('$') + 1;
35+
if (start < 1) {
36+
start = 0;
37+
}
38+
return what.substr(0, start) + 'bs' + what.substr(start, 1).toUpperCase() +
39+
what.substring(start + 1, what.length);
40+
};
41+
return {
42+
from: provider,
43+
to: prependBs(provider)
44+
}
45+
});
3946
return gulp.src(paths.dest + '/angular-strap.js')
4047
.pipe(ngAnnotate({
4148
add: true,
4249
remove: true,
43-
rename: [
44-
{from: '$tooltip', to: '$bsTooltip'},
45-
{from: '$button', to: '$bsButton'},
46-
{from: '$modal', to: '$bsModal'}
47-
]
50+
rename: compatProviders
51+
}))
52+
.pipe(rename(function(file) {
53+
file.extname = '.compat.js';
4854
}))
49-
.pipe(rename(function(file) { file.extname = '.compat.js'; }))
5055
.pipe(gulp.dest(paths.dest))
5156
.pipe(uglify({output: {indent_level: 2, quote_style: 1}}))
52-
.pipe(rename(function(file) { file.extname = '.min.js'; }))
57+
.pipe(rename(function(file) {
58+
file.extname = '.min.js';
59+
}))
5360
.pipe(gulp.dest(paths.dest))
54-
})
61+
});
62+
63+
var del = require('del');
64+
var path = require('path');
65+
66+
gulp.task('build', gulp.series('ng:build', 'compat', function afterBuild(done) {
67+
var paths = config.paths;
68+
// Delete useless module.* build files
69+
del(path.join(paths.dest, 'module.*'), done);
70+
}));
71+
72+
gulp.task('pages', gulp.series('ng:pages', function afterPages(done) {
73+
var paths = config.docs;
74+
return gulp.src(['bower_components/highlightjs/styles/github.css'],
75+
{cwd: paths.cwd, base: paths.cwd})
76+
.pipe(gulp.dest(paths.dest));
77+
}));
5578

5679
//
5780
// Tests

0 commit comments

Comments
 (0)