node 生成简易文件结构

var fs=require('fs')
let appName=process.argv[2]
let appPath=__dirname+'/'+appName

if(fs.existsSync(appPath)){
    console.log('目录已存在');
    process.exit()
}
fs.mkdirSync(appPath)
fs.mkdirSync(appPath+'/css')
fs.mkdirSync(appPath+'/js')
fs.mkdirSync(appPath+'/view')


if(process.argv.includes('-i')){
    fs.writeFileSync(appPath+'index.html',`
    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

</body>
</html>`)
}
console.log('项目创建完成');
posted @   7c89  阅读(80)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
点击右上角即可分享
微信分享提示