@varlet/cli
Version:
cli of varlet
19 lines (18 loc) • 653 B
JavaScript
import fse from 'fs-extra';
import { x } from 'tinyexec';
import { SITE_OUTPUT_PATH } from '../shared/constant.js';
import logger from '../shared/logger.js';
const { pathExistsSync } = fse;
export async function preview(options) {
const { port = 5500 } = options;
if (!pathExistsSync(SITE_OUTPUT_PATH)) {
logger.warning('Cannot find the site folder, you must first run the build command to build the document site');
return;
}
try {
await x('live-server', [`--port=${Number(port)}`], { nodeOptions: { cwd: SITE_OUTPUT_PATH, stdio: 'inherit' } });
}
catch (e) {
logger.error(e.toString());
}
}