Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Avoid overwrite user files
const checkFiles = ["package.json", "config.js", "config.yml", "config.toml"];
checkFiles.forEach(file => {
if (fs.existsSync(path.join(outDir, file))) {
logger.error(`Make sure your destination directory is empty.\n${outDir}`);
process.exit(0);
}
});
// Prompt questions
if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0) {
logger.warn("Remember to make sure your destination directory is empty.");
}
logger.info("Please answer the following questions:");
inquirer.prompt(questions).then(answers => {
const languageInfo = localeCode.getLanguages([answers.lang])[0];
const config = JSON.parse(
configTemplate({
options: {
title: answers.title,
name: slugify(answers.title),
description: answers.description,
language: {
code: languageInfo.code.split("-")[0],
iso: languageInfo.code,
name: languageInfo.nativeName
},
frontMatterFormat: answers.incidentFormat
}
return app.listen(port, host, () => {
// Listen the server
logger.info(`Server listening on http://${host}:${port}`);
});
};
"styl",
"stylus"
];
const stylesPath = [];
// eslint-disable-next-line no-unused-vars
for (const ext of validStylesExtension) {
const filePath = path.join(sourceDir, "theme", "default", `style.${ext}`);
if (fs.existsSync(filePath)) {
stylesPath.push(filePath);
}
}
if (stylesPath.length > 0) {
logger.info(
`Loading Styles from:\n${stylesPath
.map(p => path.relative(sourceDir, p))
.join("\n")}`
);
nuxtConfig.css.push(...stylesPath);
}
return {
nuxtConfig,
siteConfig
};
};
.on("restart", files => {
logger.info(`Restarting Server due to changes in:\n${files.join("\n")}`);
})
.on("crash", () => {
function parseConfig(filePath) {
const extension = path.extname(filePath);
let data;
logger.info(
`Reading configuration from ${chalk.yellow(`config${extension}`)}`
);
if (extension !== ".js") {
const content = fse.readFileSync(filePath, "utf-8");
if (extension === ".yml") {
data = yaml.parse(content);
} else if (extension === ".toml") {
data = toml.parse(content);
}
} else {
data = require(filePath);
}
return data || {};