aboutsummaryrefslogblamecommitdiff
path: root/generator/util.js
blob: e9b5c783f249e867f0f410d234bfaf8b420d5d65 (plain) (tree)


















                                                                         
//Copyright Chris Xiong 2019
//License: Expat (MIT)
module.exports={
	mtime_cmp:function(a,b){return _mtime_cmp(a,b);}
};
const fs=require('fs');

/*Returns true when file b exists and has a mtime no earlier than file a,
 *false otherwise.
 */
function _mtime_cmp(a,b)
{
	const mtimea=fs.statSync(a).mtimeMs;
	let mtimeb=0;
	try{
		mtimeb=fs.statSync(b).mtimeMs;
	}catch(e){return false};
	return mtimeb>=mtimea;
}