snippets-cli

0.0.3 • Public • Published

snippets-cli

In the project, some repeated code snippets are often initialized (for example: Controller/Model/Component/...), we may create new files, copy, paste, and modify names.

The thing to do with Snippets-cli is to configure this part of the repeated initialization work and generate it with commands.

Quick start

Installation

$ npm i snippets-cli -D

Configuration

  1. Create a new .snippetrc file, for example
{
  "snippets": {
    "controller": {
      // prompt message
      "name": "Create a new controller",
      // The relative path where the template is located
      "template": "./snippets/controller.js.snippet",
      // target generation path
      "target": "./controller"
    },
    "model": {
      "name": "新建模型",
      "template": "./snippets/model.js.snippet",
      "target": "./model"
    },
    "component": {
      "name": "新建组件",
      "template": "./snippets/component.js.snippet",
      "target": "./component"
    },
    ...
  }
}

the following properties:

  • name: prompt message
  • template: ** Note: The file name format is {custom name}.{filename suffix}.snippet **
  • target: target generation directory
  1. Configure script: { 'tpl': 'snippet' } in package.json`

Usage

After configuration, execute npm run tpl in the project root directory, select the corresponding template, and enter the file name to generate the template.

Screenshot

Package Sidebar

Install

npm i snippets-cli@0.0.3

Version

0.0.3

License

ISC

Unpacked Size

17.7 kB

Total Files

15

Last publish

Collaborators

  • ycjcl868