mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-22 15:39:34 +00:00
added linux and windows versions of watch functions
This commit is contained in:
parent
f46cd4a1ff
commit
f1bf2d7598
4 changed files with 28 additions and 8 deletions
|
|
@ -25,7 +25,7 @@ var CloudFunc = {
|
|||
SHORTNAMELENGTH : 16
|
||||
};
|
||||
|
||||
/*
|
||||
/*1
|
||||
* Функция убирает последний слеш,
|
||||
* если он - последний символ строки
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
var fs = require('fs');
|
||||
var crypto = require('crypto');
|
||||
|
||||
/* varible contain all watched file names
|
||||
* {name: true}
|
||||
*/
|
||||
var FileNames = {};
|
||||
var i=0;
|
||||
var FileNames = {};
|
||||
|
||||
/* function thet use for crossplatform
|
||||
* access to fs.watch or fs.watchFile function
|
||||
*/
|
||||
var fs_watch = null;
|
||||
var on_fs_watch =null;
|
||||
var fs_watch = null;
|
||||
var on_fs_watch = null;
|
||||
var firstFileRead_b = true;
|
||||
var Manifest = '';
|
||||
|
||||
setWatachFunctions();
|
||||
|
||||
|
|
@ -38,9 +40,13 @@ exports.watch = function(pFileName){
|
|||
catch(pError){
|
||||
console.log(pError);
|
||||
}
|
||||
|
||||
Manifest += pFileName + '\n';
|
||||
FileNames[pFileName] = true;
|
||||
}
|
||||
else if(firstFileRead_b){
|
||||
processManifest();
|
||||
firstFileRead_b = false;
|
||||
}
|
||||
};
|
||||
|
||||
function onWatch (pFileName){
|
||||
|
|
@ -55,4 +61,18 @@ function onWatchFile(pFileName){
|
|||
if(pCurr.mtime !== pCurr.pPrev.mtime)
|
||||
console.log('file ' + pFileName + 'is changed');
|
||||
};
|
||||
}
|
||||
|
||||
function processManifest(){
|
||||
Manifest = 'CACHE MANIFEST\n' +
|
||||
'#' + new Date() + '\n' +
|
||||
'CACHE:\n' +
|
||||
Manifest +
|
||||
'NETWORK:\n' +
|
||||
'*';
|
||||
|
||||
console.log(Manifest);
|
||||
fs.writeFile('cloudcmd.appcache', Manifest, function(){
|
||||
console.log('cloudcmd.appcache refreshed');
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue