mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(time) add raw option
This commit is contained in:
parent
aef0451013
commit
59b43c59f7
4 changed files with 17 additions and 18 deletions
|
|
@ -41,16 +41,13 @@
|
|||
break;
|
||||
|
||||
case 'time':
|
||||
time.get(path, function(error, time) {
|
||||
var timeStr;
|
||||
|
||||
if (!error)
|
||||
timeStr = time.toString();
|
||||
|
||||
callback(error, timeStr);
|
||||
});
|
||||
time.get(path, callback);
|
||||
break;
|
||||
|
||||
case 'time raw':
|
||||
time.get(path, callback);
|
||||
break;
|
||||
|
||||
default:
|
||||
commander.getDirContent(path, callback);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
exports.isFileChanged = function(name, callback) {
|
||||
var readTime = Times[name];
|
||||
|
||||
time.get(name, function(error, fileTime) {
|
||||
time.get(name, 'raw', function(error, fileTime) {
|
||||
var json, timeChanged;
|
||||
|
||||
if (error) {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@
|
|||
var fs = require('fs'),
|
||||
Util = require('../util');
|
||||
|
||||
object.get = function(filename, options, callback) {
|
||||
var noOptions = Util.isFunction(options);
|
||||
object.get = function(filename, option, callback) {
|
||||
var isRaw = option === 'raw';
|
||||
|
||||
if (!callback && noOptions)
|
||||
callback = options;
|
||||
if (!callback)
|
||||
callback = option;
|
||||
|
||||
Util.checkArgs(arguments, ['filename', 'callback']);
|
||||
|
||||
fs.stat(filename, function(error, stat) {
|
||||
var time, timeRet;
|
||||
|
|
@ -24,13 +26,13 @@
|
|||
if (!error) {
|
||||
time = stat.mtime;
|
||||
|
||||
if (options && options.str)
|
||||
timeRet = time;
|
||||
else
|
||||
if (isRaw)
|
||||
timeRet = time.getTime();
|
||||
else
|
||||
timeRet = time;
|
||||
}
|
||||
|
||||
Util.exec(callback, error, timeRet);
|
||||
callback(error, timeRet);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
};
|
||||
|
||||
function getTime(callback) {
|
||||
time.get(FILE, function(error, time) {
|
||||
time.get(FILE, 'raw', function(error, time) {
|
||||
if (error)
|
||||
callback(error);
|
||||
else if (FileTime === time) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue