mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
feature(ischanged) rm log
This commit is contained in:
parent
b09c9b2ca2
commit
4cabdd5172
1 changed files with 7 additions and 19 deletions
|
|
@ -5,17 +5,16 @@
|
|||
DIR_JSON = __dirname + '/../../json/',
|
||||
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
Util = require('../util'),
|
||||
time = require('./timem'),
|
||||
|
||||
CHANGES_NAME = DIR_JSON + 'changes',
|
||||
CHANGES_JSON = CHANGES_NAME + '.json',
|
||||
NAME_SHORT = DIR_JSON + 'changes',
|
||||
NAME = NAME_SHORT + '.json',
|
||||
|
||||
Times = {};
|
||||
|
||||
Util.exec.try(function() {
|
||||
Times = require(CHANGES_NAME);
|
||||
Times = require(NAME_SHORT);
|
||||
});
|
||||
|
||||
module.exports = function(name, callback) {
|
||||
|
|
@ -31,24 +30,13 @@
|
|||
Times[name] = fileTime;
|
||||
json = Util.stringifyJSON(Times);
|
||||
|
||||
writeFile(CHANGES_JSON, json);
|
||||
fs.writeFile(NAME, json, function(error) {
|
||||
if (error)
|
||||
Util.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
callback(error, timeChanged);
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Функция записывает файла
|
||||
* и выводит ошибку или сообщает,
|
||||
* что файл успешно записан
|
||||
*/
|
||||
function writeFile(name, data) {
|
||||
fs.writeFile(name, data, function(error) {
|
||||
var baseName = path.basename(name),
|
||||
msg = 'file ' + baseName + ' written...';
|
||||
|
||||
Util.log(error || msg);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue