8000 Merge pull request #1284 from dreef3/features/umd · sumit-jaiswal/restangular@f174316 · GitHub
[go: up one dir, main page]

Skip to content

Commit f174316

Browse files
committed
Merge pull request mgonto#1284 from dreef3/features/umd
Features/umd
2 parents de8a48b + a1f23f1 commit f174316

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,33 @@
3131
"dependencies": {
3232
"lodash": ">=1.3.0"
3333
},
34+
"peerDependencies": {
35+
"angular": ">=1.3.12"
36+
},
3437
"devDependencies": {
38+
"angular-mocks": "^1.4.8",
3539
"grunt": "^0.4.5",
36-
"grunt-bower": "*",
37-
"grunt-bower-task": "*",
3840
"grunt-cli": ">= 0.1.7",
3941
"grunt-contrib-concat": "*",
4042
"grunt-contrib-jshint": "*",
4143
"grunt-contrib-uglify": "*",
42-
"grunt-conventional-changelog": "0.0.12",
44+
"grunt-bower": "*",
45+
"grunt-bower-task": "*",
4346
"grunt-karma": "latest",
47+
"grunt-conventional-changelog": "0.0.12",
4448
"grunt-zip": "*",
4549
"karma": "^0.13.19",
4650
"karma-chrome-launcher": "~0.1.2",
4751
"karma-firefox-launcher": "~0.1.3",
4852
"karma-jasmine": "~0.1.5",
4953
"karma-mocha-reporter": "0.2.8",
50-
"karma-phantomjs-launcher": "~0.1.2"
54+
"karma-jasmine": "~0.1.5",
55+
"karma-chrome-launcher": "~0.1.2",
56+
"karma-phantomjs-launcher": "~0.1.2",
57+
"karma-firefox-launcher": "~0.1.3"
5158
},
5259
"scripts": {
5360
"test": "grunt test --verbose"
5461
},
5562
"license": "MIT"
56-
}
63+
}

src/restangular.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
(function() {
1+
(function (root, factory) {
2+
// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
3+
if (typeof define === 'function' && define.amd) {
4+
define(['angular', 'lodash'], factory);
5+
} else if (typeof module === 'object' && module.exports) {
6+
module.exports = factory(require('angular'), require('lodash'));
7+
} else {
8+
// No global export, Restangular will register itself as Angular.js module
9+
factory(root._, root.angular);
10+
}
11+
}(this, function (_, angular) {
212

313
var restangular = angular.module('restangular', []);
414

@@ -1346,17 +1356,5 @@ restangular.provider('Restangular', function() {
13461356
return createServiceForConfiguration(globalConfiguration);
13471357
}];
13481358
});
1349-
1350-
})();
1351-
1352-
1353-
/**
1354-
* This lets you inject the module into angularjs using the commonjs require
1355-
* syntax with browserify.
1356-
*/
1357-
/* jshint ignore:start */
1358-
if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports){
1359-
var _ = require('lodash');
1360-
module.exports = 'restangular';
1361-
}
1362-
/* jshint ignore:end */
1359+
return restangular.name;
1360+
}));

test/restangularSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ describe("Restangular", function() {
309309
};
310310

311311
CallbackManager.firstErrorInterceptor = function(response) {
312-
expect(response.status).toEqual(404);
312+
expect(Number(respo 48D0 nse.status)).toEqual(404);
313313
};
314314
CallbackManager.secondErrorInterceptor = function() {};
315315

0 commit comments

Comments
 (0)
0