fix #3 by reloading metadata prior to each build

This commit is contained in:
AJ ONeal 2015-01-21 02:41:12 -07:00
parent a73ea68402
commit e3a24e9652
1 changed files with 34 additions and 28 deletions

View File

@ -17,7 +17,9 @@ angular.module('myApp.build', ['ngRoute'])
; ;
function init() { function init() {
DesiraeService.meta().then(function (desi) { scope.extensions = ['md', 'html'];
return DesiraeService.meta().then(function (desi) {
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.site = desi.site; scope.site = desi.site;
@ -30,13 +32,13 @@ angular.module('myApp.build', ['ngRoute'])
// this is the responsibility of the build system (Dear Desi), not the library (Desirae) // this is the responsibility of the build system (Dear Desi), not the library (Desirae)
scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev'); scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev');
return desi;
}).catch(function (e) { }).catch(function (e) {
window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details."); window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details.");
console.error(e); console.error(e);
throw e; throw e;
}); });
scope.extensions = ['md', 'html'];
} }
scope.onError = function (e) { scope.onError = function (e) {
@ -49,33 +51,37 @@ angular.module('myApp.build', ['ngRoute'])
}; };
scope.buildOne = function (envstr) { scope.buildOne = function (envstr) {
var env return DesiraeService.reset().then(function () {
; return init().then(function () {
var env
;
// TODO is there a legitimate case where in addition to base_path (root of the blog) // TODO is there a legitimate case where in addition to base_path (root of the blog)
// a user would need owner_base? i.e. school.edu/~/rogers/blog school.edu/~/rogers/assets // a user would need owner_base? i.e. school.edu/~/rogers/blog school.edu/~/rogers/assets
if ('production' === envstr) { if ('production' === envstr) {
env = { env = {
url: scope.production_url url: scope.production_url
, base_url: scope.production_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1') , base_url: scope.production_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1')
, base_path: scope.production_url.replace(/https?:\/\/[^\/#?]+/, '') , base_path: scope.production_url.replace(/https?:\/\/[^\/#?]+/, '')
, compiled_path: 'compiled' , compiled_path: 'compiled'
, since: 0 , since: 0
, onError: scope.onError , onError: scope.onError
}; };
} else { } else {
env = { env = {
url: scope.development_url url: scope.development_url
, base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1') , base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1')
, base_path: scope.development_url.replace(/https?:\/\/[^\/#?]+/, '') , base_path: scope.development_url.replace(/https?:\/\/[^\/#?]+/, '')
, compiled_path: 'compiled_dev' , compiled_path: 'compiled_dev'
, since: 0 , since: 0
, onError: scope.onError , onError: scope.onError
}; };
} }
return DesiraeService.build(env).then(function () { return DesiraeService.build(env).then(function () {
DesiraeService.write(env); DesiraeService.write(env);
});
});
}); });
}; };