chore(appcache) add " "

This commit is contained in:
coderaiser 2013-09-26 06:32:15 +00:00
parent 8472ec1669
commit 1df8f01758

View file

@ -2,7 +2,7 @@
(function(){
"use strict";
if(!global.cloudcmd)
if (!global.cloudcmd)
return console.log(
'# appcache.js' + '\n' +
'# -----------' + '\n' +
@ -52,7 +52,7 @@
lCurrentName = pFileNames[i];
if (Util.isObject(lCurrentName))
for(lName in lCurrentName) {
for (lName in lCurrentName) {
FallBack_s += lName + ' ' + lCurrentName[lName] + '\n';
watch(lCurrentName[lName]);
}
@ -67,26 +67,27 @@
exports.createManifest = function(){
var lAllNames = main.require('node_modules/minify/hashes');
if(lAllNames)
for(var lName in lAllNames){
if(lName.indexOf('min') > 0)
if (lAllNames)
for (var lName in lAllNames){
if (lName.indexOf('min') > 0)
lName = 'node_modules/minify/min/' + lName;
exports.watch(lName);
}
processManifest();
};
exports.watch = function(pFileName){
exports.watch = function(pFileName) {
Util.log(pFileName + ' is watched');
if(!FileNames[pFileName] &&
pFileName !== './cloudcmd.appcache'){
if (!FileNames[pFileName] &&
pFileName !== './cloudcmd.appcache') {
/* adding try...catch
* if watched files would be more then system limit
*/
var lWatch_f = function(){
Util.tryCatch(function(){
var lWatch_f = function() {
Util.tryCatch(function() {
fs_watch(pFileName, on_fs_watch(pFileName));
});
};
@ -94,26 +95,26 @@
/* if file.exists function exist and
* file actually exists
*/
if(fs.exists)
if (fs.exists)
fs.exists(pFileName, lWatch_f);
else lWatch_f();
else
lWatch_f();
NamesList_s += pFileName + '\n';
FileNames[pFileName] = true;
}
else if(firstFileRead_b){
} else if (firstFileRead_b) {
processManifest();
firstFileRead_b = false;
}
};
function setWatachFunctions(){
if(main.WIN32){
function setWatachFunctions() {
if (main.WIN32) {
/* good on windows */
fs_watch = fs.watch;
on_fs_watch = onWatch;
}
else{
else {
/* good on linux */
fs_watch = fs.watchFile;
on_fs_watch = onWatchFile;
@ -121,24 +122,24 @@
}
function onWatch (){
return function(pEvent, pFileName){
function onWatch () {
return function(pEvent, pFileName) {
Util.log(pEvent);
Util.log('file ' + pFileName + ' is changed');
processManifest();
};
}
function onWatchFile(pFileName){
return function(pCurr, pPrev){
if(pCurr.mtime !== pPrev.mtime){
function onWatchFile(pFileName) {
return function(pCurr, pPrev) {
if (pCurr.mtime !== pPrev.mtime) {
Util.log('file ' + pFileName + ' is changed');
processManifest();
}
};
}
function processManifest(){
function processManifest() {
Manifest = 'CACHE MANIFEST\n' +
'#' + new Date() + '\n' +
'CACHE:\n' +
@ -148,7 +149,7 @@
'FALLBACK:\n' +
FallBack_s;
fs.writeFile('cloudcmd.appcache', Manifest, function(){
fs.writeFile('cloudcmd.appcache', Manifest, function() {
Util.log('cloudcmd.appcache refreshed');
});
}