Last active
September 3, 2021 15:00
-
-
Save auser/8533721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp', ['myApp.services']) | |
.config(function(AppStateProvider) { | |
AppStateProvider | |
.setTesting(@@testing) | |
.setProxyServer(@@proxyServer) | |
.setBackendUrl(@@backendUrl) | |
.setSocketUrl(@@socketUrl); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp.services') | |
.provider('AppStateService', function() { | |
var testingFlag = false, | |
autoTestFlag = false, | |
proxyServer = 'http://appapp.herokuapp.com/', | |
backendUrl = 'http://localhost:3000', | |
socketUrl = 'http://localhost:3000'; | |
this.setTesting = function(bool) { | |
if (typeof bool != 'undefined') { | |
this.testingFlag = bool; | |
} else { | |
this.testingFlag = true; | |
} | |
return this; | |
} | |
this.setProxyServer = function(server) { | |
proxyServer = server || proxyServer; | |
return this; | |
} | |
this.setBackendUrl = function(server) { | |
backendUrl = server || backendUrl; | |
return this; | |
} | |
this.setSocketUrl = function(server) { | |
socketUrl = server || socketUrl; | |
return this; | |
} | |
this.setAutoTest = function() { this.autoTestFlag = true; } | |
this.$get = function() { | |
var self = this; | |
var service = { | |
testMode: function() { return self.testingFlag; }, | |
autoTestingMode: function() { return service.testMode() && autoTestFlag; }, | |
proxyServer: function() { return proxyServer; }, | |
backendUrl: function() { return backendUrl; }, | |
socketUrl: function() { return socketUrl; } | |
} | |
return service; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"proxyServer": "'http://appapp.herokuapp.com/'", | |
"backendUrl": "'http://localhost:3000'", | |
"socketUrl": "'http://localhost:3000'", | |
"testing": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env = process.env.ENV || 'dev'; | |
// ... | |
replace: { | |
dev: { | |
options: { | |
patterns: [{ | |
json: grunt.file.readJSON(__dirname + '/config/' + env + '.json'), | |
app: '<%= yeoman.app %>/scripts/app.js' | |
}] | |
}, | |
files: [ | |
{ | |
expand: true, | |
cwd: '<%= yeoman.app %>', | |
src: ['scripts/app.js'], | |
dest: 'dev' | |
} | |
] | |
}, | |
dist: { | |
options: { | |
patterns: [{ | |
json: grunt.file.readJSON(__dirname + '/config/' + env + '.json') | |
}] | |
}, | |
files: [ | |
{ | |
expand: true, | |
cwd: '<%= yeoman.dist %>', | |
src: ['scripts/scripts.js'], | |
dest: '<%= yeoman.dist %>' | |
} | |
] | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment