利用node一键生成开发文件结构树

发布于2017年12月23日 15:23:46

在我们开发一个新项目之前,我们不免重复的去新建一个个相同的文件夹结构,这不免浪费时间。根据任何有规律的重复性的动作都可以用代码去解决的年代,那么这一重复动作就可以来用node来解决了。原理是根据express框架,利用node来生成的。

操作步骤:

1、全局安装node环境(node官网:https://nodejs.org/zh-cn/)

2、安装完成后,新建文件夹 demo;

3、将server.js拷贝置demo中;

4、win+r允许cmd ,切换到demo文件夹目录下,运行node server即可。

文件具体目录结构可按实际开发自己定义,以下是楼主常用的开发目录:

var mkDir = [
       {
           name: "src",
           child: [
              {
                 name: "assets",
                 child: [
                   {
                       name: "images"
                   },
                   {
                       name: "css",
                       child: [
                         {
                             name: 'reset.css'
                         },
                         {
                            name: 'style.css'
                         }
                       ]
                   },
                   {
                      name: "js",
                      child: [
                        {
                            name: 'common.js'
                        }
                      ]
                   },
                   {
                       name: "less",
                       child: [
                         {
                             name: 'style.less'
                         }
                       ]
                   },
                   {
                       name: "fonts"
                   }
                 ]
                 },
                 {
                       name: "views",
                       child: [
                         {
                             name: "common",
                             // child: [
                                  // {
                                        // name: "header.html"
                                  // },
                                  // {
                                        // name: "footer.html"
                                  // }
                              // ]
                        },
                     // {
                             // name: "index.html"
                     // }
                   ]
              },
         ]
     }
];

 

生成的效果图如下:

 

github地址:https://github.com/WGinit/init-structure

 

 

本文共 29 个回复

  • mind vault 2025/10/14 23:52

    **mind vault** mind vault is a premium cognitive support formula created for adults 45+. It’s thoughtfully designed to help maintain clear thinking

  • mindvault 2025/10/17 22:00

    **mindvault** mindvault is a premium cognitive support formula created for adults 45+. It’s thoughtfully designed to help maintain clear thinking

  • sugarmute 2025/10/19 01:23

    **sugarmute** sugarmute is a science-guided nutritional supplement created to help maintain balanced blood sugar while supporting steady energy and mental clarity.

  • gl pro 2025/10/19 05:42

    **gl pro** gl pro is a natural dietary supplement designed to promote balanced blood sugar levels and curb sugar cravings.

  • prostadine 2025/10/19 09:28

    **prostadine** prostadine is a next-generation prostate support formula designed to help maintain, restore, and enhance optimal male prostate performance.

  • vittaburn 2025/10/19 15:01

    **vittaburn** vittaburn is a liquid dietary supplement formulated to support healthy weight reduction by increasing metabolic rate, reducing hunger, and promoting fat loss.

  • glucore 2025/10/19 15:05

    **glucore** glucore is a nutritional supplement that is given to patients daily to assist in maintaining healthy blood sugar and metabolic rates.

  • prodentim 2025/10/19 15:06

    **prodentim** prodentim an advanced probiotic formulation designed to support exceptional oral hygiene while fortifying teeth and gums.

  • synaptigen 2025/10/19 15:25

    **synaptigen** synaptigen is a next-generation brain support supplement that blends natural nootropics, adaptogens

  • nitric boost 2025/10/19 15:26

    **nitric boost** nitric boost is a dietary formula crafted to enhance vitality and promote overall well-being.

  • mitolyn 2025/10/19 17:54

    **mitolyn** mitolyn a nature-inspired supplement crafted to elevate metabolic activity and support sustainable weight management.

  • wildgut 2025/10/19 18:01

    **wildgut** wildgutis a precision-crafted nutritional blend designed to nurture your dog’s digestive tract.

  • zencortex 2025/10/19 18:14

    **zencortex** zencortex contains only the natural ingredients that are effective in supporting incredible hearing naturally.

  • yusleep 2025/10/19 19:04

    **yusleep** yusleep is a gentle, nano-enhanced nightly blend designed to help you drift off quickly, stay asleep longer, and wake feeling clear.

  • breathe 2025/10/20 02:30

    **breathe** breathe is a plant-powered tincture crafted to promote lung performance and enhance your breathing quality.

  • pineal xt 2025/10/20 15:11

    **pineal xt** pinealxt is a revolutionary supplement that promotes proper pineal gland function and energy levels to support healthy body function.

  • energeia 2025/10/20 15:37

    **energeia** energeia is the first and only recipe that targets the root cause of stubborn belly fat and Deadly visceral fat.

  • prostabliss 2025/10/20 16:30

    **prostabliss** prostabliss is a carefully developed dietary formula aimed at nurturing prostate vitality and improving urinary comfort.

  • boostaro 2025/10/20 16:58

    **boostaro** boostaro is a specially crafted dietary supplement for men who want to elevate their overall health and vitality.

  • potent stream 2025/10/20 21:37

    **potent stream** potent stream is engineered to promote prostate well-being by counteracting the residue that can build up from hard-water minerals within the urinary tract.

  • hepatoburn 2025/10/21 13:08

    **hepatoburn** hepatoburn is a premium nutritional formula designed to enhance liver function, boost metabolism, and support natural fat breakdown.

  • hepatoburn 2025/10/21 17:41

    **hepatoburn** hepatoburn is a potent, plant-based formula created to promote optimal liver performance and naturally stimulate fat-burning mechanisms.

  • flow force max 2025/10/22 02:50

    **flow force max** flow force max delivers a forward-thinking, plant-focused way to support prostate health—while also helping maintain everyday energy, libido, and overall vitality.

  • prodentim 2025/10/22 04:10

    **prodentim** prodentim is a forward-thinking oral wellness blend crafted to nurture and maintain a balanced mouth microbiome.

  • cellufend 2025/10/22 04:41

    **cellufend** cellufend is a natural supplement developed to support balanced blood sugar levels through a blend of botanical extracts and essential nutrients.

  • revitag 2025/10/22 05:50

    **revitag** revitag is a daily skin-support formula created to promote a healthy complexion and visibly diminish the appearance of skin tags.

  • neurogenica 2025/10/22 05:56

    **neurogenica** neurogenica is a dietary supplement formulated to support nerve health and ease discomfort associated with neuropathy.

  • sleep lean 2025/10/23 06:03

    **sleep lean** sleeplean is a US-trusted, naturally focused nighttime support formula that helps your body burn fat while you rest.

  • memory lift 2025/10/25 00:28

    **memory lift** memory lift is an innovative dietary formula designed to naturally nurture brain wellness and sharpen cognitive performance.

回复 wildgut 取消