Node Cross-Platform Tool Library
npm install node-tool-utils --saveconst tool = require('node-tool-utils');const ip = tool.getIP();const host = tool.getHost(7001);
// http://100.10.196.1:7001tool.kill(7001);
tool.kill([7001,7002]);// return true or false
const isUsed = tool.checkPortUsed(7001);When 7001 is occupied, it will automatically detect whether 7002 is occupied. If it is not occupied, it will return. Otherwise, it will continue to increment detection. The default check is 10 times.
const port = tool.getPort(7001);const dir = path.join(__dirname, 'dist/index.html');
tool.deleteFile(dir);const dir = path.join(__dirname, 'dist');
tool.rm(dir);Open the Window or Finder or Browser of the specified path
tool.open('.'); // open Window or Finder
tool.openBrowser(); // open BrowserDefault check HTML file as homepage
const dist = path.join(__dirname, 'dist');
tool.httpserver({ port: 8088, dist },() => {});