2019-05-23 09:57:23 +00:00
|
|
|
const express = require('express');
|
|
|
|
const open = require('open');
|
|
|
|
const defaultBrowser = require('x-default-browser');
|
2019-05-24 07:24:26 +00:00
|
|
|
const outDir = path.resolve('./dist/' || process.env.OUT_DIR);
|
2019-05-23 09:57:23 +00:00
|
|
|
const app = express();
|
2019-05-24 07:24:26 +00:00
|
|
|
app.use(express.static(`${outDir}/dist`));
|
2019-05-23 09:57:23 +00:00
|
|
|
|
|
|
|
function runCommand(){
|
|
|
|
app.get('/',function(req,res){
|
|
|
|
res.sendFile('/index.html');
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(3000);
|
|
|
|
|
|
|
|
defaultBrowser(function (err, res) {
|
|
|
|
if(err) throw err;
|
|
|
|
(async () => {
|
|
|
|
await open('http://localhost:3000', {app: res.commonName});
|
|
|
|
console.log("ctrl + c to exit");
|
|
|
|
})();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
runCommand
|
|
|
|
};
|