1
+ /* jshint node: true */
1
2
'use strict' ;
3
+
2
4
var pjson = require ( './package.json' ) ;
3
5
var gulp = require ( 'gulp' ) ;
4
6
var concat = require ( 'gulp-concat' ) ;
@@ -21,6 +23,7 @@ var path = require('path');
21
23
var cheerio = require ( 'cheerio' ) ;
22
24
var argv = require ( 'yargs' ) . argv ;
23
25
var replace = require ( 'gulp-replace' ) ;
26
+ var umd = require ( 'gulp-umd' ) ;
24
27
25
28
var bumpVersion = function ( type ) {
26
29
type = type || 'patch' ;
@@ -67,22 +70,49 @@ gulp.task('build-js', function() {
67
70
. pipe ( gulp . dest ( 'build/scripts' ) )
68
71
. pipe ( stripDebug ( ) )
69
72
. pipe ( concat ( 'ng-map.js' ) )
73
+ . pipe ( umd ( {
74
+ dependencies : function ( file ) {
75
+ return [ {
76
+ name : 'angular' ,
77
+ amd : 'angular' ,
78
+ cjs : 'angular' ,
79
+ global : 'angular' ,
80
+ param : 'angular'
81
+ } ] ;
82
+ } ,
83
+ exports : function ( file ) {
84
+ return "'ngMap'" ;
85
+ } ,
86
+ //template: umdTemplates.returnExportsNoNamespace.path,
87
+ templateSource : '(function(root, factory) {\r\n' +
88
+ 'if (typeof exports === "object") {\r\n' +
89
+ 'module.exports = factory(<%= cjs %>);\r\n' +
90
+ '} else if (typeof define === "function" && define.amd) {\r\n' +
91
+ 'define(<%= amd %>, factory);\r\n' +
92
+ '} else{\r\n' +
93
+ 'factory(<%= global %>);\r\n' +
94
+ '}\r\n' +
95
+ '}(this, function(<%= param %>) {\r\n' +
96
+ '<%= contents %>\r\n' +
97
+ 'return <%= exports %>;\r\n' +
98
+ '}));'
99
+ } ) )
70
100
. pipe ( gulp . dest ( 'build/scripts' ) )
71
101
. pipe ( uglify ( { preserveComments : license } ) )
72
102
. pipe ( rename ( 'ng-map.min.js' ) )
73
103
. pipe ( gulp . dest ( 'build/scripts' ) )
74
104
. on ( 'error' , gutil . log ) ;
75
105
} ) ;
76
106
77
- gulp . task ( 'docs' , function ( ) {
78
- gulp . task ( 'docs' , shell . task ( [
79
- 'node_modules/ jsdoc/ jsdoc.js ' +
80
- ' -c node_modules/ angular-jsdoc/ common/ conf.json '+ // config file
81
- ' -t node_modules/ angular-jsdoc/ angular-template ' + // template file
82
- ' -d build/docs ' + // output directory
83
- '. /README.md ' + // to include README.md as index contents
84
- ' -r directives services' // source code directory
85
- ] ) ) ;
107
+ gulp . task ( 'docs' , function ( ) {
108
+ shell . task ( [
109
+ path . join ( 'node_module' , ' jsdoc' , ' jsdoc.js' ) +
110
+ ' -c ' + path . join ( ' node_modules' , ' angular-jsdoc' , ' common' , ' conf.json ') + // config file
111
+ ' -t ' + path . join ( ' node_modules' , ' angular-jsdoc' , ' angular-template' ) + // template file
112
+ ' -d ' + path . join ( ' build' , 'docs' ) + // output directory
113
+ ' ' + path . join ( '. /README.md' ) + // to include README.md as index contents
114
+ ' -r directives services' // source code directory
115
+ ] ) ;
86
116
} ) ;
87
117
88
118
gulp . task ( 'bump' , function ( ) { bumpVersion ( 'patch' ) ; } ) ;
@@ -156,5 +186,4 @@ gulp.task('examples:json', function() {
156
186
}
157
187
) )
158
188
. pipe ( gulp . dest ( 'testapp' ) ) ;
159
- } ) ;
160
-
189
+ } ) ;
0 commit comments