Update: 更新static-server
This commit is contained in:
@@ -2,31 +2,30 @@ const fs = require('fs')
|
|||||||
const StaticServer = require('./static-server.js');
|
const StaticServer = require('./static-server.js');
|
||||||
const SSLStaticServer = require('./static-sslserver.js');
|
const SSLStaticServer = require('./static-sslserver.js');
|
||||||
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
function deleteFile(filePath) {
|
||||||
async function deleteDirectory(dirPath) {
|
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(dirPath);
|
if (!fs.existsSync(filePath)) {
|
||||||
console.log('Directory deleted successfully.');
|
return;
|
||||||
|
}
|
||||||
|
const stats = fs.statSync(filePath);
|
||||||
|
if (stats.isFile()) {
|
||||||
|
fs.unlinkSync(filePath);
|
||||||
|
console.log('File deleted successfully.');
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error deleting directory:', err);
|
console.error('Error deleting file:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
StaticServer.run('7000');
|
StaticServer.run('7000');
|
||||||
SSLStaticServer.run('8000');
|
SSLStaticServer.run('8000');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!module.parent) {
|
if (!module.parent) {
|
||||||
deleteDirectory('./nw_cache/Default/Preferences');
|
deleteFile('./nw_cache/Default/Preferences');
|
||||||
sleep(200);
|
init();
|
||||||
init();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
module.exports = init;
|
module.exports = init;
|
||||||
|
|||||||
Reference in New Issue
Block a user