const fs = require('fs');
const config = require('./config');
const readFile = function(dir) {
	return new Promise((success, fail) => {
		fs.readFile(dir, (err, data) => {
			if (err) return fail(err);
			success(data.toString())
		})
	})
}
const rewriteFile = function(dir, data) {
	let option = {
		flag: 'w'
	};
	return new Promise((success, fail) => {
		fs.writeFile(dir, data, option, err => {
			if (err) return fail(err);
			console.log(`rewrite file ${dir} success`);
			success(data);
		})
	})
}

const buildFile = async function(dir) {
	try {
		let html = await readFile(dir);
		let tags = html.match(/<script [^>]*>/g);
		tags.forEach(tag => {
			if (tag.indexOf(config.dir.controller) === -1 && tag.indexOf(config.dir.util) === -1) {
				return false;
			}
			tag = tag.replace(/t=[0-9]{13}/g, '');
			let replace = tag.replace('.js', `.js?t=${Date.now()}`);
			html = html.replace(tag, replace);
		});
		await rewriteFile(dir, html);
	} catch (err) {
		console.log(err);
	}
}

const init = async function() {
	try {
		let commonDir = config.views ? config.views : '.';
		config.files.forEach(dir => {
			dir = `${commonDir}${dir}`
			buildFile(dir)
		})
	} catch (err) {
		console.log(err);
	}
}

init()
@@ -630,30 +630,160 @@
 ;%0A%09%09
-tags.forEach(tag =%3E %7B%0A
+let link = html.match(/%3Clink %5B%5E%3E%5D*%3E/g);%0A%09%09let timeStamp = Date.now();%0A%09%09if (tags && tags.length %3E 0) %7B%0A%09%09%09tags.forEach(tag =%3E %7B%0A%09%09%09%09var tempTag = tag;%0A%09
 %09%09%09i
@@ -877,27 +877,61 @@
 %09%09%09%09
+%09
 return
- false
 ;%0A%09%09%09
+%09
 %7D%0A
+%09%09%09%09if (tag.indexOf('t=') !== -1) %7B%0A%09%09
 %09%09%09t
@@ -975,65 +975,644 @@
 %0A%09%09%09
-let replace = tag.replace('.js', %60.js?t=$%7BDate.now()
+%09%7D%0A%09%09%09%09if (tag.indexOf('js?%22') !== -1 %7C%7C tag.indexOf(%22js?'%22) !== -1) %7B%0A%09%09%09%09%09tag = tag.replace('js?', 'js')%0A%09%09%09%09%7D%0A%09%09%09%09let replace = tag.replace('.js', %60.js?t=$%7BtimeStamp%7D%60);%0A%09%09%09%09html = html.replace(tempTag, replace);%0A%09%09%09%7D);%0A%09%09%7D%0A%09%09if (link && link.length %3E 0) %7B%0A%09%09%09link.forEach(tag =%3E %7B%0A%09%09%09%09var tempTag = tag;%0A%09%09%09%09if (tag.indexOf(config.dir.css) === -1) %7B%0A%09%09%09%09%09return;%0A%09%09%09%09%7D%0A%09%09%09%09if (tag.indexOf('t=') !== -1) %7B%0A%09%09%09%09%09tag = tag.replace(/t=%5B0-9%5D%7B13%7D/g, '');%0A%09%09%09%09%7D%0A%09%09%09%09if (tag.indexOf('css?%22') !== -1 %7C%7C tag.indexOf(%22css?'%22) !== -1) %7B%0A%09%09%09%09%09tag = tag.replace('css?', 'css')%0A%09%09%09%09%7D%0A%09%09%09%09let replace = tag.replace('.css', %60.css?t=$%7BtimeStamp
 %7D%60);%0A
+%09
 %09%09%09h
@@ -1631,16 +1631,20 @@
 eplace(t
+empT
 ag, repl
@@ -1651,20 +1651,25 @@
 ace);%0A%09%09
+%09
 %7D);%0A
+%09%09%7D%0A
 %09%09await 
@@ -1959,10 +1959,11 @@
 %0A%7D%0A%0A
-
 init()
+%0A

Create app.js